我有一个点击事件连接到我的列表视图,如图所示.
int[] GenusListIDs = { R.id.txt_ID, R.id.txt_Genus, R.id.txt_Count };
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.genusitem, cursor_genuslist, service.GenusListColumns, GenusListIDs);
ListView list_Genus = (ListView)findViewById(R.id.list_Genus);
list_Genus.setAdapter(adapter);
list_Genus.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView parent, View view, int position, long id)
{
try
{
Log.println(1, "ItemClick", view.toString());
TextView tv = (TextView)view;
String genus = (String) tv.getText();
Intent i = new Intent(getBaseContext(), Cat_Species.class);//new Intent(this, Total.class);
/*view
i.putExtra("id", id);*/
startActivity(i);
}
catch(Exception ex)
{
Log.println(1, "item-click-event", ex.getMessage());
}
}
});
我需要根据他们点击的listitem将字符串参数传递给新的intent.我想要传递的值在名为txt_Genus的listitem中.如何从listitem中获取该值以传递给intent?不要注意我的实验请哈哈.