我想从列表中选择一个项目。单击此项目时,我想打开一个新活动,并在下一个活动中显示相关项目。这是我的点击监听器的代码:
listView.setOnClickListener(new AdapterView.OnClickListener() {
String item = (String) adapterView.getItemAtPosition(i);
public onClick(AdapterView<?> adapterView, View view, int i, long l) {
// Getting item text to be able to show it in a toast.
String item = (String) adapterView.getItemAtPosition(i);
Intent intent = new Intent(MainActivity.this, AddPlaneActivity.class);
startActivity(intent);
}
});
答案 0 :(得分:0)
来自here:
context.auth.uid
Intent intent = new Intent(getBaseContext(), AddPlaneActivity.class);
intent.putExtra("EXTRA_STUFF_HERE", item);
startActivity(intent);
答案 1 :(得分:0)
尝试
lv.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,int position, long arg3)
{
Intent intent = new Intent(getBaseContext(), AddPlaneActivity.class);
intent.putExtra("Item", item);
startActivity(intent);
}
});
布局中带有android:descendantFocusability="blocksDescendants"