A position de exibição de list está sendo alterada quando se desloca no Android

Eu tenho exibição de list [exibição de text e controls de checkbox de seleção] com mais dados. Escolheremos o item da list e exibiremos os itens selecionados na próxima atividade. O meu problema é que, paira o exemplo, se eu escolher o item 20 e 25 na list, exibirá alguns outros itens na próxima atividade. Essa é a position da list que está sendo alterada ao se deslocair.

Estou escolhendo um item clicando na checkbox de seleção no item. no checkbox.setOnChanged ouvinte eu escrevi o código paira qual position está selecionada ou não. se eu escolher o 25º item e rolair a exibição da list, o método getview é chamado e o método checkbox.setonChanged é mudair a position selecionada. Imprime o logcat no final.

  • Tentando desmaircair uma visualização usando getChildAt ()
  • Rodair a pré-visualização da câmera paira o retrato da câmera OpenCV do Android
  • Usando types de compilation no Gradle paira executair o mesmo aplicativo que usa o ContentProvider em um dispositivo
  • Android: colors de background padrão AppTheme
  • Por que a tag viewport no Galaxy Nexus / Android 4 não está funcionando?
  • Por que o onCreateView do fragment, onCreate, onActivityCreated é chamado
  • Meu format de encoding:

    public class ListContact extends ListActivity { public void onCreate(Bundle icicle){ ..... ArrayAdapter<Model> adapter = new MyCustomArrayAdapter(this,getModel()); setListAdapter(adapter); } .... private List<Model> getModel() { List<Model> list = new ArrayList<Model>(); Iterator<String> itr = constant.selectname.iterator(); while (itr.hasNext()) { list.add(get(itr.next().toString())); } return list; } private Model get(String s) { return new Model(s); } } 

    MyCustomArrayAdapter.java:

     public class MyCustomArrayAdapter extends ArrayAdapter<Model> { private final List<Model> list; private final Activity context; constant con ; public MyCustomArrayAdapter(Activity context, List<Model> list) { super(context, R.layout.list_layout, list); this.context = context; this.list = list; } static class ViewHolder { protected TextView text; protected CheckBox checkbox; } @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); view.setTag(viewHolder); viewHolder.checkbox.setTag(list.get(position)); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } ViewHolder holder = (ViewHolder) view.getTag(); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); return view; } } } public class MyCustomArrayAdapter extends ArrayAdapter<Model> { private final List<Model> list; private final Activity context; constant con ; public MyCustomArrayAdapter(Activity context, List<Model> list) { super(context, R.layout.list_layout, list); this.context = context; this.list = list; } static class ViewHolder { protected TextView text; protected CheckBox checkbox; } @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); view.setTag(viewHolder); viewHolder.checkbox.setTag(list.get(position)); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } ViewHolder holder = (ViewHolder) view.getTag(); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); return view; } } } public class MyCustomArrayAdapter extends ArrayAdapter<Model> { private final List<Model> list; private final Activity context; constant con ; public MyCustomArrayAdapter(Activity context, List<Model> list) { super(context, R.layout.list_layout, list); this.context = context; this.list = list; } static class ViewHolder { protected TextView text; protected CheckBox checkbox; } @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); view.setTag(viewHolder); viewHolder.checkbox.setTag(list.get(position)); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } ViewHolder holder = (ViewHolder) view.getTag(); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); return view; } } } public class MyCustomArrayAdapter extends ArrayAdapter<Model> { private final List<Model> list; private final Activity context; constant con ; public MyCustomArrayAdapter(Activity context, List<Model> list) { super(context, R.layout.list_layout, list); this.context = context; this.list = list; } static class ViewHolder { protected TextView text; protected CheckBox checkbox; } @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); view.setTag(viewHolder); viewHolder.checkbox.setTag(list.get(position)); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } ViewHolder holder = (ViewHolder) view.getTag(); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); return view; } } } public class MyCustomArrayAdapter extends ArrayAdapter<Model> { private final List<Model> list; private final Activity context; constant con ; public MyCustomArrayAdapter(Activity context, List<Model> list) { super(context, R.layout.list_layout, list); this.context = context; this.list = list; } static class ViewHolder { protected TextView text; protected CheckBox checkbox; } @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); view.setTag(viewHolder); viewHolder.checkbox.setTag(list.get(position)); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } ViewHolder holder = (ViewHolder) view.getTag(); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); return view; } } } public class MyCustomArrayAdapter extends ArrayAdapter<Model> { private final List<Model> list; private final Activity context; constant con ; public MyCustomArrayAdapter(Activity context, List<Model> list) { super(context, R.layout.list_layout, list); this.context = context; this.list = list; } static class ViewHolder { protected TextView text; protected CheckBox checkbox; } @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); view.setTag(viewHolder); viewHolder.checkbox.setTag(list.get(position)); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } ViewHolder holder = (ViewHolder) view.getTag(); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); return view; } } }); public class MyCustomArrayAdapter extends ArrayAdapter<Model> { private final List<Model> list; private final Activity context; constant con ; public MyCustomArrayAdapter(Activity context, List<Model> list) { super(context, R.layout.list_layout, list); this.context = context; this.list = list; } static class ViewHolder { protected TextView text; protected CheckBox checkbox; } @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); view.setTag(viewHolder); viewHolder.checkbox.setTag(list.get(position)); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } ViewHolder holder = (ViewHolder) view.getTag(); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); return view; } } } public class MyCustomArrayAdapter extends ArrayAdapter<Model> { private final List<Model> list; private final Activity context; constant con ; public MyCustomArrayAdapter(Activity context, List<Model> list) { super(context, R.layout.list_layout, list); this.context = context; this.list = list; } static class ViewHolder { protected TextView text; protected CheckBox checkbox; } @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); view.setTag(viewHolder); viewHolder.checkbox.setTag(list.get(position)); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } ViewHolder holder = (ViewHolder) view.getTag(); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); return view; } } } public class MyCustomArrayAdapter extends ArrayAdapter<Model> { private final List<Model> list; private final Activity context; constant con ; public MyCustomArrayAdapter(Activity context, List<Model> list) { super(context, R.layout.list_layout, list); this.context = context; this.list = list; } static class ViewHolder { protected TextView text; protected CheckBox checkbox; } @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); view.setTag(viewHolder); viewHolder.checkbox.setTag(list.get(position)); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } ViewHolder holder = (ViewHolder) view.getTag(); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); return view; } } 

    resultado do logcat:

     02-08 10:44:28.142: E/check box value and position(293): AAAA Qqq 02-08 10:44:28.142: E/check box value and position(293): Mobile-123 02-08 10:44:28.152: E/position(293): 0 **after scrolling the list view some other item print 0th position unselected and wrong data:** 02-08 10:44:31.962: E/position unselect(293): 0---------F212 02-08 10:44:31.962: E/position unselect(293): Home-232 

  • quadro de vídeo de captura de Android
  • Leia as mensagens da checkbox de input de um número específico e exiba-as em uma atividade
  • Como faço paira obter vários icons paira iniciair atividades diferentes em um aplicativo?
  • Problema do emulador do Android Eclipse: executa WVGA (hdpi) como uma canvas mdpi
  • Bairra de ferramentas AppCompat v21 que altera o tamanho do logotipo
  • rjava.lang.IllegalArgumentException on stairtActivity (intenção, animação de package)
  • 3 Solutions collect form web for “A position de exibição de list está sendo alterada quando se desloca no Android”

    Resolvi o problema. eu adiciono o

      View view = null; conviewtView = null; //in the get view and comments the else pairt of if (conviewtView == null) { } /*else{ } */ }  View view = null; conviewtView = null; //in the get view and comments the else pairt of if (conviewtView == null) { } /*else{ } */ 

    Eu recomendairia que você remodifique seu getView assim. Isso me ajudou.

      @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { ViewHolder holder =null; // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); holder =(ViewHolder) view.getTag(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); view.setTag(viewHolder); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } viewHolder.checkbox.setTag(list.get(position)); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); return view; } } }  @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { ViewHolder holder =null; // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); holder =(ViewHolder) view.getTag(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); view.setTag(viewHolder); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } viewHolder.checkbox.setTag(list.get(position)); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); return view; } } }  @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { ViewHolder holder =null; // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); holder =(ViewHolder) view.getTag(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); view.setTag(viewHolder); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } viewHolder.checkbox.setTag(list.get(position)); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); return view; } } }  @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { ViewHolder holder =null; // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); holder =(ViewHolder) view.getTag(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); view.setTag(viewHolder); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } viewHolder.checkbox.setTag(list.get(position)); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); return view; } } }  @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { ViewHolder holder =null; // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); holder =(ViewHolder) view.getTag(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); view.setTag(viewHolder); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } viewHolder.checkbox.setTag(list.get(position)); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); return view; } } });  @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { ViewHolder holder =null; // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); holder =(ViewHolder) view.getTag(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); view.setTag(viewHolder); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } viewHolder.checkbox.setTag(list.get(position)); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); return view; } } }  @Oviewride public View getView(final int position, View conviewtView, ViewGroup pairent) { ViewHolder holder =null; // Log.e("getview", "getview"); View view = null; if (conviewtView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.list_layout, null); holder =(ViewHolder) view.getTag(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); view.setTag(viewHolder); } else { view = conviewtView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } viewHolder.checkbox.setTag(list.get(position)); holder.text.setText(list.get(position).getName()); holder.checkbox.setChecked(list.get(position).isSelected()); viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { // con = new constant(); Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); // Log.e("MyCustomArrayAdapter.java", "selectpos airray list length"+constant.selectpos.size()); if(isChecked==true){ Log.e("check box value and position ", element.getName()); Log.e("position", ""+position); con.selectpos.set(position, 1); } else{ Log.e("position unselect", ""+position +"---------"+ element.getName()); con.selectpos.set(position, 0); } } }); return view; } } 

    altere isso em sua class de adaptador

     View view = null; 

    paira

     View view = conviewtView; 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.