次のリスナーがあり、メソッドをオーバーライドしますonGroupExpand
。
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 で 2 秒後に新しいテキストが表示されます。
ただし、重要なのはExpandableListView
、その特定のアイテムのテキストは変更されないということです。onGroupExpand で背景色を設定する場合も同様です。このバグに遭遇した人はいますか?