3 つのレベルを持つ ExpandableListView があります。最初のレベルのアダプターには、TextView をレンダリングする getGroupView があり、正常に動作します。
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
TextView tv = new TextView(context);
tv.setText(mCountries.get(groupPosition).getName());
tv.setBackgroundColor(Color.BLUE);
tv.setPadding(10, 7, 7, 7);
return tv;
}
しかし今、私はそれを次のレベルに引き上げたいと思っていました..XMLを膨らませて、TextViewだけでなく、ボタンも持っています。それにもかかわらず、行をクリックしても展開されないため、機能しません。これは適応されたメソッドであり、もちろん、コンストラクターでインフレータを初期化します。
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View v = mInflater.inflate(R.layout.countries_row, null, false);
mCountryName = (TextView) v.findViewById(R.id.CountryTextView);
mCountryName.setText(mCountries.get(groupPosition).getName());
mCountryName.setBackgroundColor(Color.BLUE);
mCountryName.setPadding(10, 7, 7, 7);
mCountryExpandButton = (Button) v.findViewById(R.id.CountryExpandButton);
return v;
}
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
なぜそれが機能しないのか、そしてそれを修正する方法について誰かが光を当てることができますか? ビューの TextView を変更しているだけなので、本当に奇妙です..
よろしくお願いします!