setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_checked
,items));
it shows only one checkBox

mo5ito wrote:i Know it seems bizzare ,but how can i insert for exemple 2 checkBoxes for every item in a list View ?![]()
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_checked
,items));
it shows only one checkBox







package Android.MyExapandableListView;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.TextView;
public class main extends Activity {
/** Called when the activity is first created. */
ExpandableListAdapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.iterator);
ExpandableListView lv = (ExpandableListView)this.findViewById(R.id.ExpandableListView);
MyExpandableListAdapter questions = new MyExpandableListAdapter();
lv.setAdapter(questions);
}
public class MyExpandableListAdapter extends BaseExpandableListAdapter {
private LayoutInflater inflater =null;
private String[] groups = { "People Names", "Dog Names", "Cat Names", "Fish Names" };
private String[][] children = {
{ "Arnold", "Barry", "Chuck", "David" },
{ "Ace", "Bandit", "Cha-Cha", "Deuce" },
{ "Fluffy", "Snuggles" },
{ "Goldy", "Bubbles" }
};
public MyExpandableListAdapter()
{
this.inflater = main.this.getLayoutInflater();
}
public Object getChild(int groupPosition, int childPosition) {
return children[groupPosition][childPosition];
}
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
public int getChildrenCount(int groupPosition) {
return children[groupPosition].length;
}
public Object getGroup(int groupPosition) {
return groups[groupPosition];
}
public int getGroupCount() {
return groups.length;
}
public long getGroupId(int groupPosition) {
return groupPosition;
}
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
convertView = inflater.inflate(R.layout.child, null);
TextView question = (TextView)convertView.findViewById(R.id.nomChild);
question.setText(getChild(groupPosition, childPosition).toString());
return convertView;
}
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
ViewGroup parent) {
// TextView textView = getGenericView();
// textView.setText(getGroup(groupPosition).toString());
convertView = inflater.inflate(R.layout.group, null);
TextView question = (TextView)convertView.findViewById(R.id.nomGroup);
question.setText(getGroup(groupPosition).toString());
return convertView;
}
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
public boolean hasStableIds() {
return true;
}
}
}
Return to Other Coding-Problems
Users browsing this forum: No registered users and 6 guests