本文介绍了在不同的活动显示OnItemClickListener结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用OnItemClickListener选择从列表视图中的项目如下:
I used OnItemClickListener to select an item from the list view as follows:
listView.setTextFilterEnabled(true);
final TextView disp = (TextView) findViewById(R.id.textView1);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position,long id) {
String temp = (String) listView.getItemAtPosition(position);
disp.setText(temp);// display on screen
Toast.makeText(getBaseContext(),temparr.get(position),Toast.LENGTH_SHORT).show();
}
});
现在我想结果显示在另一个活动。我怎样才能实现呢?
Now I want to display the result in another activity. How can i achieve it?
推荐答案
您点击监听器里写这个
Intent myIntent = new Intent(YourCurentActivity.this, SecondActivity.class);
myIntent.putExtra("key", temp);
startActivity(myIntent);
在第二个活动做到这一点 -
Do this in second activity-
Bundle extras = getIntent().getExtras();
if(extras!=null)
{
String temp = extras.getString("key");
textview.setText(temp);
}
这篇关于在不同的活动显示OnItemClickListener结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!