第一种,通过
Adapter
的
parent.getAdapter
()方法来获取
adapter=new FirstListViewAdapter(list,getActivity());
listView.setAdapter(adapter);
//
监听单击项的事件
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public voidonItemClick(AdapterView<?> parent, View view, int position, long id) {
Adapter nadapter=parent.getAdapter();
//
获得单条的数据
Map<String,Object> map= (Map<String, Object>)nadapter.getItem(position);
//
获得当前点击的新闻的编号
StringnId=map.get(“id”).toString();
//
跳转窗体
Intent intent=newIntent(getActivity(), NewContentActivity.class);
intent.putExtra(“id”,nId);
getActivity().startActivity(intent);
}
});
}
第二种,通过
TextView
获得
id
的值得方法来获取
listView
.setOnItemClickListener(
new
AdapterView.OnItemClickListener(){
@Override
public void
onItemClick(AdapterView<?>parent, View view,
int
position,
long
id) {
TextView textid = (TextView)view.findViewById(R.id.
textid
);
lvid
= textid.getText().toString();
Intent intent =
new
Intent(
context
,ContentActivity.
class
);
intent.putExtra(
“id”
,
lvid
);
context
.startActivity(intent);
}
});