我使用的ExpandableListview
有多个不同的child layout
。
我在点击第二个Editext
时显示Group header
,但Editext
不可见。
我也使用spinner来处理数据
但是没有数据的Editext
无效
请帮我解决这个问题。 提前谢谢。
getChilView中的
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
_childText = (String) getChild(groupPosition, childPosition);
int itemType = getChildType(groupPosition,childPosition);
Log.e("childPosition", "karjeevch "+childPosition);
ViewHolder viewHolder = null;
switch (itemType) {
case 0:
viewHolder = null;
if (convertView==null) {
viewHolder=new ViewHolder();
convertView = infalInflater.inflate(R.layout.list_child_shape, null);
viewHolder.shape_name = (CheckBox) convertView.findViewById(R.id.shape_chk_box);
viewHolder.img_shape_icon=(ImageView)convertView.findViewById(R.id.img_shape);
imageLoader.DisplayImage("http://rosycontact.com/shashvat/images/"+_childText+".png", viewHolder.img_shape_icon);
viewHolder.shape_name.setText(_childText);
convertView.setTag(viewHolder);
final CheckBox shape_name_temp=viewHolder.shape_name;
viewHolder.shape_name.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if (shape_name_temp.isChecked()==true) {
All_link.SHAPE=shape_name_temp.getText().toString();
}
}
});
//new PerformBackgroungTask().execute();
}
else{
viewHolder=(ViewHolder)convertView.getTag();
}
return convertView;
//break;
case 1:
viewHolder = null;
if (convertView==null) {
viewHolder=new ViewHolder();
convertView = infalInflater.inflate(R.layout.list_child_carat, null);
viewHolder.carat_from = (TextView) convertView.findViewById(R.id.ed_carat_from);
viewHolder.carat_to = (TextView) convertView.findViewById(R.id.ed_carat_to);
viewHolder.carat_from.setText("jdsv");
viewHolder.carat_to.setText("jdsv");
All_link.CARAT_FROM=viewHolder.carat_from.getText().toString();
All_link.CARAT_TO=viewHolder.carat_to.getText().toString();
}
else{
viewHolder=(ViewHolder)convertView.getTag();
}
return convertView;
case 2:
viewHolder = null;
if (convertView==null) {
viewHolder=new ViewHolder();
convertView = infalInflater.inflate(R.layout.list_child_color, null);
viewHolder.color_from = (Spinner) convertView.findViewById(R.id.spn_color_from);
viewHolder.color_to = (Spinner) convertView.findViewById(R.id.spn_color_to);
ArrayAdapter adapter = new ArrayAdapter(_context, android.R.layout.simple_spinner_item, SearchActivity.color_list);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
viewHolder.color_from.setAdapter(adapter);
viewHolder.color_to.setAdapter(adapter);
convertView.setTag(viewHolder);
final Spinner color_from_temp=viewHolder.color_from;
final Spinner color_to_temp=viewHolder.color_to;
// Changing textcolor
viewHolder.color_from.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
All_link.COLOR_FROM=color_from_temp.getSelectedItem().toString();
((TextView) parent.getChildAt(0)).setTextColor(Color.parseColor("#003974"));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
viewHolder.color_to.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
All_link.COLOR_TO=color_to_temp.getSelectedItem().toString();
((TextView) parent.getChildAt(0)).setTextColor(Color.parseColor("#003974"));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
}
else{
viewHolder=(ViewHolder)convertView.getTag();
}
return convertView;
在活动中
listDataHeader.add("Shape");
listDataHeader.add("Carat");
listDataChild.put(listDataHeader.get(1), new ArrayList<String>());
list_child_carat.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FEFFFF" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<EditText
android:id="@+id/ed_carat_from"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:textColor="#272727"
android:textSize="15dp"
android:layout_alignParentLeft="true"
android:hint="From"/>
<TextView
android:id="@+id/txt_carat_to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#272727"
android:textSize="15dp"
android:layout_centerInParent="true"
android:text="to"/>
<EditText
android:id="@+id/ed_carat_to"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:textColor="#272727"
android:textSize="15dp"
android:layout_below="@+id/img_shape"
android:layout_alignParentRight="true"
android:hint="To"/>
</RelativeLayout>
</RelativeLayout>