issue to select checkbox in onViewCreated()

前端 未结 2 931
被撕碎了的回忆
被撕碎了的回忆 2021-01-25 11:53

I need to select automatically all checkboxes when I launch my app in onViewCreated().

With this code:

@Override
public void onViewCreated(V         


        
相关标签:
2条回答
  • 2021-01-25 12:17

    Try with plAdapter.notifyDataSetChanged() after for loop ends. In adapter after set the value, you have to refresh the listview.

    0 讨论(0)
  • 2021-01-25 12:26

    In your adapters getView() method, try this:

    @Override
    public View getView(final int position, final View convertView, final ViewGroup parent) {
    
        ...........
        ...................
    
        if (isChecked) {
            holder.chkBox.setChecked(true);
    
            holder.spinner.setVisibility(View.VISIBLE);
            holder.np.setVisibility(View.VISIBLE);
        } else {
            holder.chkBox.setChecked(false);
    
            holder.spinner.setVisibility(View.GONE);
            holder.np.setVisibility(View.GONE);
         }
    
         .........
         ...................
    
         return row;
    }
    
    0 讨论(0)
提交回复
热议问题