The Toast of the onListItemClick method never appears, does anyone know what I did wrong? Code:
public class TiposFragment extends ListFragment {
private ArrayList<Tipo> tipos;
private TipoAdapter tipoAdapter;
private int selecionado;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
try {
Bundle bundle = getArguments();
if (bundle != null) {
tipos = bundle.getParcelableArrayList("tipos");
}
} catch (Exception e) {
Toast.makeText(getContext(), e.toString(), Toast.LENGTH_LONG).show();
}
if (tipos != null) {
try {
tipoAdapter = new TipoAdapter(getContext(), tipos);
setListAdapter(tipoAdapter);
ListView listaTipos = getListView();
listaTipos.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
// Toast.makeText(getContext(),String.valueOf(listaTipos.getCount()),Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getContext(), e.toString(), Toast.LENGTH_LONG).show();
}
}
}
@Override
public void onListItemClick(ListView lv, View v, int position, long id) {
super.onListItemClick(lv, v, position, id);
selecionado = tipoAdapter.getItem(position).tipCod;
Toast.makeText(getContext(), String.valueOf(selecionado), Toast.LENGTH_SHORT).show();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_tipo_trilha, container, false);
return view;
}