How to create listview onItemclicklistener

后端 未结 3 959
面向向阳花
面向向阳花 2020-12-06 05:21

I want to create listview. I got the value from the JSON. Here I got the value from the json into listview but i can\'t get the onItemclickListener method. Why this is

3条回答
  •  暖寄归人
    2020-12-06 05:31

    Try this :

    contests_listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView parent, View view,int position, long id) {
            String item = (String) contests_listView.getItemAtPosition(position);
            Toast.makeText(this,"You selected : " + item,Toast.LENGTH_SHORT).show();                
        }
    });
    

提交回复
热议问题