«

andriod中SimpleAdapter+listview,点击item 传值事件

时间:2024-3-2 18:29     作者:韩俊     分类: Android


直接上代码

listView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            // 第position现被单击时激发该方法
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {

                    Map<String,Integer> map=(Map<String, Integer>) indexActivity.this.adapter.getItem(position);
                    int spid=map.get("spid");

                    Toast.makeText(getApplicationContext(), "单击的是商品编号="+spid,
                            Toast.LENGTH_LONG).show();
                    Intent intent = new Intent();
                    intent.setClass(indexActivity.this, PromessActivity.class);
                    intent.putExtra("spid", spid);  
                    indexActivity.this.startActivity(intent);

            }

        });


标签: android

热门推荐