android in ListView under multiple CheckBox Select problem, if the number is more than one screen CheckBox, some are selected, not selected parts of the problem occurs, ask the experts how to solve?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
It is not that a state record it? The reason is certainly not set on the state.
Reply:
In a group which will be out of the question?
Reply:
This problem, I have not met
Reply:
How much checkbox is automatically generated based on the number of recording data in the database. Without whether to rewrite Adapter can solve this problem?
Reply:
Have not encountered over the CheckBox try fullscreen
Reply:
Please fulcrum move it!
Reply:
Put your code to select all unselected Tieshanglai see it
Mainly to see how to deal with
Adapter Lane
The most stupid way: ListView instance method to find instances of child checkbox, and then one by one set, it should be no problem
Reply:
Need to customize the ListView MyAdapter
/ *
* Custom ListView's MyAdapter
* /
public final class ViewHolder {
public TextView iid;
public EditText info;
public CheckBox cbx;
public ImageView img;
}
Set
I do not understand you can ask
Reply:
I know rewrite Adapter, I also realized function. Only such a solution?
Reply:
Reply:
Amount. . Finally see his reply to
Reply:
http://download.csdn.net/source/3120614 This is what you want
Reply:
Here is an example I used to see, this should be able to solve your problem now:
package com.listViewTest;
import java.util.ArrayList;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
public class ListViewTest extends ListActivity {
/ ** Called when the activity is first created. * /
Context context = null;
Listlist = new ArrayList ();
CheckBox checkbox;
private LinearLayout lr;
@ Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.main);
context = getApplicationContext ();
setListAdapter (new MyListAdapter ());
}
@ Override
protected void onListItemClick (ListView l, View v, int position, long id) {
/ / TODO Auto-generated method stub
super.onListItemClick (l, v, position, id);
lr = (LinearLayout) v;
checkbox = (CheckBox) lr.getChildAt (1);
if (list.contains (new Integer (position))) {
checkbox.setChecked (false);
list.remove (new Integer (position));
} Else {
checkbox.setChecked (true);
list.add (new Integer (position));
}
}
class MyListAdapter extends BaseAdapter {
String data [] = new String [] {"apple", "pear", "banana", "orange", "apple", "pear", "banana", "orange", "apple", "pear", "banana", "orange"};
public int getCount () {
/ / TODO Auto-generated method stub
return data.length;
}
public Object getItem (int position) {
/ / TODO Auto-generated method stub
return data [position];
}
public long getItemId (int position) {
/ / TODO Auto-generated method stub
return position;
}
public View getView (int position, View convertView, ViewGroup parent) {
if (null == convertView) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate (R.layout.list_item, parent, false);
}
TextView text = (TextView) convertView.findViewById (R.id.info);
checkbox = (CheckBox) convertView.findViewById (R.id.checkstatus);
checkbox.setTag (new Integer (position));
text.setText (data [position]);
if (list! = null) {
checkbox.setChecked ((list.contains (new Integer (position))));
} Else {
checkbox.setChecked (false);
}
return convertView;
}
}
}
Reply:
Reply:
You remove the cache that it should be cached problems
No comments:
Post a Comment