1个回答
展开全部
//定交一个listview
ListView lv=(ListView)findViewById(R.id.ListView01);
//数据源绑定
SimpleAdapter adp = new SimpleAdapter(this,
list, R.layout.main_list,
new String[]{"OrderType","Orderdate","Price","OrderState","Id"},
new int[]{R.id.tvTitle,R.id.tvDate,R.id.tvPrice,R.id.tvState,R.id.tvId});
//显示数据
lv.setAdapter(adp);
//item点事件
lv.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
Intent intent = new Intent(OrderActivity.this,DaiActivity.class);//OrderActivity.this,当前页面,DaiActivity.class转至的页面
//item内的数据保存在map中
Map<String, String> map = (Map<String, String>)lv.getItemAtPosition(arg2);
//需要的数据在intent中
intent.putExtra("id", map.get("Id"));
//跳转页面
OrderActivity.this.startActivity(intent);
}
});
另一个页面
Intent intent = getIntent();
String id = intent.getStringExtra("id");
ListView lv=(ListView)findViewById(R.id.ListView01);
//数据源绑定
SimpleAdapter adp = new SimpleAdapter(this,
list, R.layout.main_list,
new String[]{"OrderType","Orderdate","Price","OrderState","Id"},
new int[]{R.id.tvTitle,R.id.tvDate,R.id.tvPrice,R.id.tvState,R.id.tvId});
//显示数据
lv.setAdapter(adp);
//item点事件
lv.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
Intent intent = new Intent(OrderActivity.this,DaiActivity.class);//OrderActivity.this,当前页面,DaiActivity.class转至的页面
//item内的数据保存在map中
Map<String, String> map = (Map<String, String>)lv.getItemAtPosition(arg2);
//需要的数据在intent中
intent.putExtra("id", map.get("Id"));
//跳转页面
OrderActivity.this.startActivity(intent);
}
});
另一个页面
Intent intent = getIntent();
String id = intent.getStringExtra("id");
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询