How to get value onListItemClick and pass it to another activity

前端 未结 2 1493
北海茫月
北海茫月 2021-01-06 00:00

I have a listView which has information inside and when i click one row it must give me all the details under that selected row , in that select row i have image, imagename,

2条回答
  •  有刺的猬
    2021-01-06 00:32

    I beleive you are extending ArratAdapter and must be having row.xml inflated under getView.And lets assume your row.xml have attributes imagename and price.Then you will use something like below snippet to extract those values.

    mListView.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView  myAdapter, View myView, int myItemInt, long mylng) {
    
    
                String imageName = ((TextView) myView.findViewById(R.id.imageName)).getText().toString();
                String price = ((TextView) myView.findViewById(R.id.price)).getText().toString();
    
            }
    
        });
    

提交回复
热议问题