从一个类通过与特定的ID ArrayList的另一个android系统 [英] Pass the arraylist with particular id from one class to another in android

查看:283
本文介绍了从一个类通过与特定的ID ArrayList的另一个android系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过传递数组列表与ID传递从一类到另一个数据。

I want to pass the data from one class to another by passing the arraylist with id ..

 listviewfirst.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub

                    Intent i= new Intent(MainActivity.this,Questionactivity.class);
                    // To pass data 
                   i.putExtra("uploadarraylist", uploadarraylist);
                   startActivity(i);


        }

在这里,我传递数组列表,但基于ID没有我想要将数据传递到下一个活动页面。

Here i have pass the array list but based on id no i want to pass the data to next activity page.

可能有人帮助我..

推荐答案

你有的ArrayList&LT;&HashMap的LT;弦乐,对象&gt;&GT; uploadarraylist

和你想通过特定的的HashMap 给定选择指数下一个活动,然后,

And you want to pass particular HashMap for given selected index to next Activity then,

listviewfirst.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
         HashMap<String, Object> hashMap = uploadarraylist.get(arg2);
         Intent i= new Intent(MainActivity.this,Questionactivity.class);
         // To pass data                 
         i.putExtra("hashMap", hashMap);
         startActivity(i);
        }

而在 Questionactivity

Intent intent = getIntent();    
HashMap<String, Object> hashMap = (HashMap<String, Object>) intent.getSerializableExtra("hashMap");

这篇关于从一个类通过与特定的ID ArrayList的另一个android系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆