how can I put开发者_开发技巧 the Name of my clicked ListView Item in an Intent?
barlist.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(Barlocator.this, Barinfo.class);
i.putExtra( , );
startActivity(i);
}
});
Thanks for help! :)
You are on the right track, just need to define a name for your extra argument, and retrieve the actual Name to put into it. We don't know what your Adapter contains, but start from here:
final Adapter adapter = parent.getAdapter();
final YourItemType item = adapter.getItem( position );
final Name = item.getNameSomehow();
take a string like String s="item" the use like this
String listItem=adapter.getItem(position);
i.putExtra( s+position,listItem );
精彩评论