在我的應用程序中,我有一個ExpandableListView
與BaseExpandableListAdapter
。該方法getChildView
樣子:ListViewAdapter不同風格的行
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
MyCustomObject myObject = (MyCustomObject)getGroup(groupPosition)).getValue().get(childPosition);
if(convertView==null){
LayoutInflater inflater = (LayoutInflater) this.ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.list_item, null);
}
TextView lbl = (TextView) convertView.findViewById(R.id.lbl);
lbl.setText(myObject.getText());
return convertView;
}
我想改變這取決於對myObject
財產佈局的背景(和其他功能)。我的第一個嘗試是定義不同的風格,並嘗試動態改變視圖的風格,但這是不可能的。
什麼是最好和最有效的方法來實現這一目標?
謝謝!
除了背景之外,你還想改變什麼? – nKn
我還不確定,但讓我說我想添加一個圖標(或根據屬性更改其可見性)。 – mario595