Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使用intent传递单击的列表项的位置,并在代码中显示的我的switch case函数中使用该数据_Android - Fatal编程技术网

Android 如何使用intent传递单击的列表项的位置,并在代码中显示的我的switch case函数中使用该数据

Android 如何使用intent传递单击的列表项的位置,并在代码中显示的我的switch case函数中使用该数据,android,Android,列表视图项单击并使用意图传递位置 ListView lstview = (ListView) findViewById(R.id.listView); lstview.setAdapter(new CustomAdapter(this)); lstview.setOnItemClickListener(new OnItemClickListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)

列表视图项单击并使用意图传递位置

ListView lstview = (ListView) findViewById(R.id.listView);
    lstview.setAdapter(new CustomAdapter(this));
    lstview.setOnItemClickListener(new OnItemClickListener() {

        @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position,
                long arg3) {
            // TODO Auto-generated method stub


            Bundle basket=new Bundle();
            basket.getInt("pos",position);
            Intent a= new Intent(Customlist.this,Customgrid.class);
            a.putExtras(basket);
            startActivity(a);


        }
    });
}

在你的听众中,它应该是

basket.putInt("pos",position);
不是

basket.putInt("pos",position);
basket.getInt("pos",position);