我有如下因素听众和我覆盖的方法onGroupExpand
:的Android ExpandableListView错误
list.setOnGroupExpandListener(new OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
long groupId = adapter.getGroupId(groupPosition);
Toast.makeText(getBaseContext(), "Group = " + adapter.getGroupId(groupPosition), Toast.LENGTH_SHORT).show();
Log.d(TAG, "Group expanded");
View v = adapter.getGroupView((int) groupId, true, null, list);
TextView txt = (TextView)v.findViewById(R.id.expandable_first_layer);
Log.d(TAG, "txt: " + txt.getText());
txt.setText("Tru-ru-ru");
Log.d(TAG, "txt: " + txt.getText());
}
});
我看到正确的文本时,我调用txt.getText()
第一次。然后在第二个txt.getText()
在我的LogCat中看到新的文本。
但问题是ExpandableListView
不会更改它在该特定项目中的文本。与在onGroupExpand中设置背景颜色相同。有没有人遇到这个错误?
你必须notifydatasetchange使得该列表中的任何更改后刷新expandablelist。 – Rakshi 2012-07-11 09:56:43
不,adapter.notifyDataSetChanged()不能解决问题。 – Stas 2012-07-11 10:00:40
我不明白为什么你要设置文本,当你扩大名单 – Rakshi 2012-07-11 10:07:00