I have an ExpandableListView with three levels. In the adapter for the first level, I have a getGroupView that displays a TextView, and it works fine.
@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; }
But now I wanted to go to the next level .. just bloating XML and instead of TextView, Button too; however, it does not work then, since it does not expand when I click on a line. This is an adapted method and, of course, in the constructor, I initialize the inflation:
@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);
Can anyone talk about why it does not work, and how to fix it? This is really strange because it is just a change to the TextView to view.
Many thanks!
noloman
source share