1
我是Android新手。我想創建一個可擴展的ListView,其中1行具有自定義信息,必須在manin線程中指定,而不是在佈局中進行硬編碼。帶有自定義組頭的Android ExpandableListView
我想要一個圖像和2個文字瀏覽。我想我需要一個自定義的佈局文件,但我不確定在代碼中如何調用它。請協助。
以下是我的自定義適配器內的GropView fxn。我想情況下0加載自定義佈局文件
public View getGroupView(int groupPosition, boolean arg1, View convertView,
ViewGroup arg3) {
String laptopName = (String) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.group_item, null);
}
TextView item = (TextView) convertView.findViewById(R.id.laptop);
item.setTypeface(null, Typeface.BOLD);
item.setText(laptopName);
this.context = (Activity) context;
switch (groupPosition) {
case 0:
convertView.setBackgroundColor(this.context.getResources()
.getColor(R.color.dark_blue));
convertView.inflate(R.layout.first_row_layout, 0, arg3);
break;
case 1:
convertView.setBackgroundColor(this.context.getResources()
.getColor(R.color.purple));
break;
case 2:
convertView.setBackgroundColor(this.context.getResources()
.getColor(R.color.green));
break;
default:
break;
}
return convertView;
}