내 프로젝트의 탭 하나를 나타내는 조각이 있습니다. 이 프래그먼트는 ExpandableListAdapater를 호스팅합니다. 확장 가능한 목록은 일부 정보를 표시하는 그룹당 하나의 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