Ce que je veux faire est, quand je clique sur l'enfant dans ExpandableListView il va changer le parent (groupView) en fonction d'un enfant sélectionné. En bref, c'est comme un <select><option/></select>
en HTML.Comment faire pour afficher TextView dans le groupe dans ExpandableListView
C'est le ChildView
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final String childText = (String) getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater inflater= (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.list_item, null);
}
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.i("Onclick CHild: ", childText);
//This is where I want to setText the View of its groupView
}
});
TextView txtListChild = (TextView) convertView
.findViewById(R.id.listItem);
txtListChild.setText(childText);
return convertView;
}
C'est le groupView
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
String headerTitle = (String) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
switch(groupPosition){
case 0:{
convertView = infalInflater.inflate(R.layout.type_header, null);
break;
}
case 1:{
convertView = infalInflater.inflate(R.layout.make_header, null);
break;
}
case 2:{
convertView = infalInflater.inflate(R.layout.model_header, null);
break;
}
case 3:{
convertView = infalInflater.inflate(R.layout.engine_header, null);
break;
}
case 4:{
convertView = infalInflater.inflate(R.layout.weight_header, null);
break;
}
}
}
Holder holder = new Holder(this._context);
holder.title = (TextView) convertView.findViewById(R.id.headerTitle);
holder.title.setText(headerTitle);
return convertView;
}
merci beaucoup –