0

我得到了这个带有适配器的 ListView:

date_status_pending_listview.setAdapter(arrayAdapter_pending);

其中适配器定义如下:

arrayAdapter_pending = new SimpleAdapter(context, dates_pending, R.layout.date_status_list_item, columns, to){

                        public View getView(int position, View convertView, ViewGroup parent) {


                            if (convertView == null) {
                                LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                                convertView = vi.inflate(R.layout.date_status_list_item, null);
                            }

                            TextView tt = (TextView) convertView.findViewById(R.id.text_uid);
                            tt.setText(dates_pending.get(position).get("id_request"));
....

                            return convertView;
                        }
                    };

我想要的是在单击一个项目时获取 uid_request 的值,然后转到另一个活动。

// A C T I O N    B U T T O N S (I T E M   S E L E C T E D - P E N D I N G) 
    date_status_pending_listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent,android.view.View v, int position, long id) {

        }
    });

我应该怎么点?

4

2 回答 2

0

只需在填充 textViews 时做同样的事情

date_status_pending_listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent,android.view.View v, int position, long id) {

          dates_pending.get(position).get("id_request");

         //Go To Another Activity

        }
    });
于 2013-10-28T11:14:12.350 回答
0
      date_status_pending_listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
       public void onItemClick(AdapterView<?> parent,android.view.View v, int position, long id) {
        String id = dates_pending.get(position).get("id_request");
        Intent i=new Intent(this,NextScreen.class);
        i.putExtra("ID",id);
        startActivity(i);

      }
  });

在下一个屏幕上:

  Bundle extras=getIntent().getExtras();
  String id=extras.getString("ID");
  System.out.println("SELECTED ID IS"+id);
于 2013-11-19T06:21:15.147 回答