How to create listview onItemclicklistener

后端 未结 3 851
面向向阳花
面向向阳花 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:25

    Use This:

     contests_listView.setOnItemClickListener(new AdapaterView.OnItemClickListener() {
    
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1,
                    int position, long id) {
    
                Intent in1 = new Intent(Activites_Activity.this, Activity_display.class);
    
                startActivity(in1);
            }
        });
    
    0 讨论(0)
  • 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();                
        }
    });
    
    0 讨论(0)
  • 2020-12-06 05:47

    Try this code:

    protected void onListItemClick(ListView l, View v, int position, long id) {
    
    super.onListItemClick(l, v, position, id);
    
    Toast.makeText(this, "message", Toast.LENGTH_LONG).show();
    }
    
    0 讨论(0)
提交回复
热议问题