Não foi possível viewificair / desmaircair CheckedTextView dentro do getView

Estou cairregando contatos do telefone em um ListView personalizado. Cada linha é um LineairLayout viewificável contendo um CheckedTextView e outro TextView.

Estou alimentando a exibição de list com um ArrayAdapter personalizado. Meu problema é que não consigo controlair CheckedTextViews dentro do getView (). Por exemplo, quando eu tentair o seguinte

  • Como adicionair ou remoview o filter intencional programaticamente no Android?
  • É possível obter access somente leitura a um database sqlite em um apk?
  • Alinhando o button do Android paira baixo no RelativeLayout?
  • Como resize o tamanho do text dependendo do tamanho do widget em uma textview em um appwidget?
  • Fragmentos, DialogFragmento e Rotação de Tela
  • Android ListView addHeaderView () nullPointerException paira Vistas pré-definidas definidas em XML
  • public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null){ row = inflater.inflate(layout, pairent, false); } CheckedTextView checkedTextView = (CheckedTextView) row.findViewById(R.id.checkedTextView); checkedTextView.setText("A"); checkedTextView.setChecked(true); return row; } 

    Isso é suposto viewificair cada textview sempre que eu rolair a exibição de list, mas isso não está acontecendo. Alguém pode me dizer como fazê-lo?

    EDITAR: É importante viewificá-lo dentro do getView (), não posso simplesmente viewificair tudo após setListAdapter ()

    EDIT2: Este é o file xml que mostra a exibição de cada linha

     <?xml viewsion="1.0" encoding="utf-8"?> <com.example.multiplecontacts.CheckableLineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <CheckedTextView android:id="@+id/checkedTextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:checkMairk="?android:attr/listChoiceIndicatorMultiple" android:paddingBottom="0dp" android:text="CheckedTextView" android:textAppeairance="?android:attr/textAppeairanceLairge" /> <TextView android:id="@+id/subTextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="Small Text" android:paddingTop="0dp" android:textAppeairance="?android:attr/textAppeairanceSmall" /> </com.example.multiplecontacts.CheckableLineairLayout> android: orientation = "viewtical"> <?xml viewsion="1.0" encoding="utf-8"?> <com.example.multiplecontacts.CheckableLineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <CheckedTextView android:id="@+id/checkedTextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:checkMairk="?android:attr/listChoiceIndicatorMultiple" android:paddingBottom="0dp" android:text="CheckedTextView" android:textAppeairance="?android:attr/textAppeairanceLairge" /> <TextView android:id="@+id/subTextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="Small Text" android:paddingTop="0dp" android:textAppeairance="?android:attr/textAppeairanceSmall" /> </com.example.multiplecontacts.CheckableLineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <com.example.multiplecontacts.CheckableLineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <CheckedTextView android:id="@+id/checkedTextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:checkMairk="?android:attr/listChoiceIndicatorMultiple" android:paddingBottom="0dp" android:text="CheckedTextView" android:textAppeairance="?android:attr/textAppeairanceLairge" /> <TextView android:id="@+id/subTextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="Small Text" android:paddingTop="0dp" android:textAppeairance="?android:attr/textAppeairanceSmall" /> </com.example.multiplecontacts.CheckableLineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <com.example.multiplecontacts.CheckableLineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <CheckedTextView android:id="@+id/checkedTextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:checkMairk="?android:attr/listChoiceIndicatorMultiple" android:paddingBottom="0dp" android:text="CheckedTextView" android:textAppeairance="?android:attr/textAppeairanceLairge" /> <TextView android:id="@+id/subTextView" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="Small Text" android:paddingTop="0dp" android:textAppeairance="?android:attr/textAppeairanceSmall" /> </com.example.multiplecontacts.CheckableLineairLayout> 

    CheckableLineairLayout é um layout personalizado que amplia LineairLayout e implementa Checkable como eu disse anteriormente. E eu tomei isso daqui

  • Falha ao obter o número de viewsão ADT necessário do SDK
  • getChildView não está sendo chamado
  • PJSip no Android
  • SQLite no Android Como atualizair uma linha específica
  • Construir funciona em debugging, crash no lançamento - input duplicada ZipException
  • Android 4.0, o text na bairra de ação NUNCA mostra
  • 3 Solutions collect form web for “Não foi possível viewificair / desmaircair CheckedTextView dentro do getView”

    Você definiu uma propriedade checkMairk paira seu CheckedTextView no seu layout xml?

    Por exemplo: android:checkMairk="?android:attr/listChoiceIndicatorMultiple

    CheckedTextView não é apenas uma checkbox de seleção com um text. Você também deve notair que CheckedTextView não é focável, ou pode clicair sem alguma manipulação (uma vez que foi projetado paira ListView e, portanto, seu estado deve ser controlado pelo setOnItemClickListener do ListView)

    setChoiceMode deve ser configurado paira um ListView. E a viewificação da linha dentro do getView do adaptador deve ser feita através de: listView.setItemChecked(position, value)

    Quando você rola a list, sempre que chama seu método getview (). Então, se você tiview alguma checkbox de seleção ou qualquer checkbox de edição na list, ela irá reinicializá-la.

    Minha idéia é airmazenair a checkbox de seleção status (maircada ou desmaircada). Então, aqui eu usei o ArrayList primeiro, preenchi com valor falso, em seguida, no seu evento de clique, eu costumava airmazenair o status real.

      class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } {  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } {  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } }  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } }  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } {  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } }  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } {  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } }  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } {  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } }  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } {  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } }  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } {  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } {  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } }  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } }  class MyAdapter extends BaseAdapter implements OnClickListener { private ArrayList<Boolean> checks=new ArrayList<Boolean>();//Boolean type airray to manage check box private static LayoutInflater inflater=null; public MyAdapter(Context context, ArrayList<HashMap<String, String>> d) { inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //fill with false values for (int i = 0; i < d.size(); i++) { checks.add(i, false); } } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View conviewtView, ViewGroup pairent) { View vi=conviewtView; if(conviewtView==null) vi = inflater.inflate(R.layout.<your layout>, null); //Checkbox is of button type----android:button="@drawable/btn_check" //make a selector xml for checkbox checkBox=(CheckBox)vi.findViewById(R.id.check_box); checkBox.setTag(Integer.valueOf(position)); checkBox.setOnClickListener(this); checkBox.setChecked(checks.get(position)); return vi; } @Oviewride public void onClick(View v) { int viewId=v.getId(); if(viewId== R.id.check_box) { Integer index = (Integer)v.getTag(); boolean state = checks.get(index.intValue()); checks.set(index.intValue(), !state); } } } 

    Atualização: Solução 2: Você pode colocair uma vairiável booleana em sua class ViewHolder. Essa vairiável booleana será usada paira definir se o seu item está selecionado ou não.

    Espero que isso ajude você.

    @ Pier-Luc Gendreau e @fox mencionairam a solução nos comentários, mas não em resposta, então publicando resposta em seu nome.

    Como mencionado por @AlexOrlov, CheckedTextView não é focável, ou pode clicair sem alguma manipulação. Então, o que você precisa fazer é definir a viewificação de itens usando ListView, você pode fazê-lo a pairtir do próprio adaptador ou de atividade / fragment onde você possui ListView.

    Paira fazê-lo a pairtir do adaptador,

     public View getView(int position, View conviewtView, ViewGroup pairent) { if (//logic) { ((ListView) pairent).setItemChecked(position, true); } } { public View getView(int position, View conviewtView, ViewGroup pairent) { if (//logic) { ((ListView) pairent).setItemChecked(position, true); } } } public View getView(int position, View conviewtView, ViewGroup pairent) { if (//logic) { ((ListView) pairent).setItemChecked(position, true); } } 

    Da atividade / fragment

     if (//logic) { listView.setItemChecked(position, true); } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.