У меня есть фрагмент, который представляет одну вкладку моего проекта. В этом фрагменте размещен расширенный интерфейсListAdapater. Расширяемый список - это просто один ребенок TextView для каждой группы, который отображает некоторую информацию.Как свернуть текущую группу в ExpandableListView
То, что я пытаюсь достичь, - это реализовать двойной щелчок по расширяемому TextView. При двойном нажатии TextView он разрушит эту группу.
Я попытался свернуть группу внутри адаптера, но по какой-то причине он получает SO. Я знаю, что мне нужно реализовать GestureDetector, но я не могу реализовать это внутри адаптера или даже фрагмента.
Мой фрагмент:
public class FragmentProgramInfo extends Fragment
{
View view;
ExpandableListView expandableListView;
ExpandableListAdapterProgramInfo expandableListAdapterProgramInfo;
public FragmentProgramInfo()
{}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
view = inflater.inflate(R.layout.fragment_program_info, container, false);
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
expandableListAdapterProgramInfo = new ExpandableListAdapterProgramInfo(getActivity());
expandableListView = (ExpandableListView) view.findViewById(R.id.ELV_program_info_list);
expandableListView.setAdapter(expandableListAdapterProgramInfo);
}
}
Мой Adapater:
public class ExpandableListAdapterProgramInfo extends BaseExpandableListAdapter
{
Activity context;
View masterView;
private String[] listGroups;
private String[][] listChilds;
public ExpandableListAdapterProgramInfo(Activity context)
{
this.context = context;
interfaceExpandableListAdapterProgramInfo = (InterfaceExpandableListAdapterProgramInfo) context;
masterView = context.getWindow().getDecorView().findViewById(android.R.id.content);
/// Intitialize strings of listGroups and listChilds
}
@Override
public View getGroupView(final int listGroupPosition, boolean isExpanded, View view, ViewGroup viewGroup)
{
LayoutInflater layoutInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(view == null)
view = layoutInflater.inflate(R.layout.list_group_program_info, viewGroup, false);
TextView tvListGroupProgramInfo = (TextView) view.findViewById(R.id.TV_list_group_program_info);
tvListGroupProgramInfo.setText(getGroup(listGroupPosition).toString());
return view;
}
@Override
public View getChildView(final int listGroupPosition, final int listChildPosition, boolean isLastChild,
View view, ViewGroup viewGroup)
{
LayoutInflater inflater = context.getLayoutInflater();
view = inflater.inflate(R.layout.list_child_program_info, viewGroup, false);
TextView tvListChildProgramInfo = (TextView) view.findViewById(R.id.TV_list_child_program_info);
tvListChildProgramInfo.setText(listChilds[listGroupPosition][listChildPosition]);
return view;
}
/// Override other methods of ELV
}
Я не уверен, как это помогает. – Samuel