How open new activity clicking an item in listview?

前端 未结 10 2018
我在风中等你
我在风中等你 2020-11-30 10:17

I can\'t start a new activity clicking over an item in my listview. I want that onItemClick can open the ApkInfoActivity.. Actually when i click no

相关标签:
10条回答
  • 2020-11-30 11:00

    Use This for doing your work

     list.setOnItemClickListener(new AdapterView.onItemClickListener() {
       @Override
       public void onItemClick(AdapterView<?> adapter, View view, int position, long arg) {
          Intent appInfo = new Intent(YourActivity.this, ApkInfoActivity.class);
           startActivity(appInfo);
       } 
    });
    
    0 讨论(0)
  • 2020-11-30 11:00

    Use this:

    Intent appInfo = new Intent(CurrentActivity.this, ApkInfoActivity.class); startActivity(appInfo);

    0 讨论(0)
  • 2020-11-30 11:00
        lv.setOnItemClickListener(new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapter, View view, int position, long arg) {
              if(position==0){
             Intent appInfo = new Intent(SwahiliService.this, DisplayActivity.class);
              startActivity(appInfo);
          } 
              if(position==1){
                  Intent english=new Intent(SwahiliService.this,EnglishService.class);
                  startActivity(english);
              }
              if(position==2){
                  Toast.makeText(getApplicationContext(),"You have selected pst3", Toast.LENGTH_LONG).show();
              }
       }});
    
    0 讨论(0)
  • 2020-11-30 11:03

    Try changing the visibility from protected to public for your method header.

    Edit

    Now that I look at it, your method header is actually wrong. It should be the following:

    public abstract void onItemClick (AdapterView<?> parent, View view, int position, long id)
    

    The variables must be in the same order as they are in the Interface they implement.

    0 讨论(0)
提交回复
热议问题