我使用SimpleAdapter有一个类似懒惰列表的外观,它可以在线从MySQL服务器获取数据。在ListItemClick上,我想将信息发送到一个新活动,该活动将使用该数据(比如索引号)显示从MySQL DB再次获得的特定结果。
由于列表是动态生成的,我需要一种方法将这个动态生成的数据发送到新活动。
谢谢。
答案 0 :(得分:0)
您已使用intent
进行了设置,您必须在intent
听众的onItemSelected
方法上发送此listview
。
像这样:
Intent i = new Intent(this, YourActivity.class);
i.putExtra(name, yourId);
startActivity(i);
并在新onCreate
activity
中接收此内容
Intent i = getIntent();
Bundle extras = i.getExtras();
if (extras != null) {
int id = extras.getInt(name);
}
答案 1 :(得分:0)
如果你查看OnItemSelected
的参数,那里有一个名为long id
(last arg)的东西,这里的id是SqliteDB表的 _id
你正在SimpleCursorAdapter中使用。
正如@Leondros所提到的,你使用意图并使用putExtra()传递信息。
在这里,您必须使用解析将 long _id
转换为字符串,然后在意图的接收方将其恢复。