开发者

Name of clicked ListView Element Intent

开发者 https://www.devze.com 2023-04-04 20:58 出处:网络
how can I put开发者_开发技巧 the Name of my clicked ListView Item in an Intent? barlist.setOnItemClickListener(new OnItemClickListener() {

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

精彩评论

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

关注公众号