android listactivity onCheckedChangeListener

前端 未结 2 508
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-28 20:11

I\'m developing an app and I have one ListActivity, which has choice mode set to choice_mode_multiple. now i want to override method, which is called w

2条回答
  •  没有蜡笔的小新
    2021-01-28 20:31

    Set onlistitemclick listener to listview , then in itemclick method you can get mylistView.getCheckedItemCount() , write the code of the operation to be performed.

    If this is not clear let me know what you want to implement when item is checked.

    mylistView = (ListView)customView.findViewById(R.id.mylist);
    mylistView.setAdapter(mFolderAdapter);
    
    mylistView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    
    
    mylistView.setOnItemClickListener(new OnItemClickListener() {
    
                    @Override
                    public void onItemClick(AdapterView arg0, View v,
                            int arg2, long arg3) {
                        // TODO Auto-generated method stub
    
    
    
                            if(mylistView.isItemChecked(arg2)){
    
      //Dooperation
    
                                } 
    // or 
    if(mylistView.getCheckedItemCount()>1){
      //Dooperation
    }
    
                    }
                });
    

提交回复
热议问题