开发者

Name of clicked ListView Element Intent

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 );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜