--- Обновлено ниже ---андроид slidingmenu и expandablelistview не работает
У меня возникли проблемы с показывающей ExpandableListView (ПДВ) внутри SlidingMenu фрагмента. Фрагмент загружен отлично, и если я использую ListView, проблем нет. Я применил пользовательский адаптер для загрузки представления для групп и дочерних элементов, и все работает так, как ожидалось, когда ПЗВ загружается в обычную активность.
Я отлаживал его целую вечность и рисовал фактический ELV (я устанавливал фон на красный, и он показывает, где я его ожидал), но группы и дочерние элементы не нарисованы. Все соответствующие методы в адаптере вызываются при загрузке активности с помощью скользящего меню (например, getGroupView). Может ли кто-нибудь помочь мне получить фактические группы и детей, чтобы они отображались внутри SlidingMenu?
Это мои П в макете XML:
<ExpandableListView
android:id="@+id/trackermenutypes_explist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:transcriptMode="disabled"
android:layout_gravity="right"
android:layout_margin="15dp"
/>
методе в адаптере, чтобы получить вид:
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.listitem_typegroup, null);
}
((TextView) convertView.findViewById(R.id.listitem_typegroup_name)).setText(mTypeGroups.get(groupPosition).getName());
Log.d(TAG, "Returning GroupView for group \"" + mTypeGroups.get(groupPosition).getName() + "\"");
return convertView;
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.listitem_type, null);
}
((TextView) convertView.findViewById(R.id.listitem_type_name)).setText(mGroupedTypes.get(groupPosition).get(childPosition).getName());
Log.d(TAG, "Returning ChildView for type \"" + mGroupedTypes.get(groupPosition).get(childPosition).getName() + "\"");
return convertView;
}
Моих фрагментов onActivityCreated метод (с рабочим ListView закомментированным в нижней части) :
@Override
public void onActivityCreated(Bundle savedInstanceState) {
Log.d(TAG, "onActivityCreated");
super.onActivityCreated(savedInstanceState);
mContext = (TrackerActivity) getActivity();
//lTypesList = getListView();
lExpList = (ExpandableListView)mContext.findViewById(R.id.trackermenutypes_explist);
mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
mTypeGroupDataSource = new TypeGroupDataSource(mContext);
mTypeGroupDataSource.open();
mTypeGroups = mTypeGroupDataSource.getAllTypeGroups();
mTypeDataSource = new TypeDataSource(mContext);
mTypeDataSource.open();
mTypes = mTypeDataSource.getTypesOfClub(DataService.DEFAULT_CLUB_ID);
mTypes.addAll(mTypeDataSource.getTypesOfClub(mPrefs.getLong(DataService.PREFS_CLUB_ID, -1)));
TypeAdapter typeAdapter = new TypeAdapter(mContext, mTypeGroups, mTypes);
lExpList.setAdapter(typeAdapter);
lExpList.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
mContext.updateCurrentType(id);
mContext.getSlidingMenu().toggle();
return true;
}
});
Log.d(TAG, "Expanding " + typeAdapter.getGroupCount() + " groups");
for (int i = 0; i < typeAdapter.getGroupCount(); i++){
lExpList.expandGroup(i);
}
//TODO Implement "Add Type" feature
/*ArrayAdapter<TypeData> typeAdapter = new ArrayAdapter<TypeData>(mContext, R.layout.listitem_type, R.id.listitem_type_name, mTypes);
setListAdapter(typeAdapter);
lTypesList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View item, int position, long id) {
mContext.updateCurrentType(position);
mContext.getSlidingMenu().toggle();
}
});*/
}
--- UPDATE --- я вычислил путь к г et it, чтобы нарисовать группы и элементы, сделав мой фрагмент ListFragment и используя setList. Это своего рода взлом, так как сейчас, например, setAdapter не работает с моим пользовательским BaseExpandableListAdapter. И когда я вызываю его в фактическом списке (из findViewByID), он не реагирует на события касания. Итак, теперь у меня есть прекрасный список, который нельзя использовать. Какие-либо предложения?