我需要在课堂上使用onListItemClick,它是一个扩展片段,我不知道如何在课堂上使用它,有人知道我怎么称呼它?
public class VisitaFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_visita, container, false);
return rootView;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Visitas visita = new Visitas();
List<Visita> visitas = visita.getVisitas();
final ListVisitaAdapter visitaAdapter = new ListVisitaAdapter(getActivity(), visitas);
ListView listVisitas = (ListView) getActivity().findViewById(R.id.lv_visita_emvisita);
listVisitas.setAdapter(visitaAdapter);
//-->> onListItemClick
}
}
答案 0 :(得分:0)
listVisitas.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
答案 1 :(得分:0)
扩展android.app.ListFragment而不是Fragment。它包含一个可以覆盖的onListItemClick()方法。