Note that there are some explanatory texts on larger screens.

plurals
  1. POadding custom button in list view on the right side in android
    primarykey
    data
    text
    <p>Hi Good evening to all,</p> <p>i am trying to create custom list view where in the right side i am adding one button initially i ser the text of button to "ADD", now when i click on that button first time text should change to Remove, now my problem is when i click on Button with ADD text, it set Remove text on diff. positions, like if i click on position 1 then it set Remove text to 6th or 7 and 12th like this,</p> <p>please help me on this any help is appreciated. my code is here</p> <pre><code> // TODO Auto-generated method stub // View row = null; if (convertView == null) { // if(row==null) convertView = mInflater.inflate(R.layout.apps_list, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder = new ViewHolder(); holder.appName = (TextView) convertView.findViewById(R.id.app_name); holder.addRemove = (Button) convertView.findViewById(R.id.add_or_remove); holder.cb = (CheckBox)convertView.findViewById(R.id.cb); convertView.setTag(holder); } else { // Get the ViewHolder back to get fast access to the TextView // and the ImageView. holder = (ViewHolder) convertView.getTag(); } prefsEditor = myPrefs.edit(); holder.appName.setText(optionalAppsArray.get(position)); String addOrRemove = holder.addRemove.getText().toString(); int pos = position; holder.addRemove.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub try { if(!bool){ holder.addRemove.setText("Add"); bool = true; }else { holder.addRemove.setText("remove"); bool = false; } } catch (Exception e) { // TODO: handle exception } } }); return convertView; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload