Note that there are some explanatory texts on larger screens.

plurals
  1. POonListItemClick in ListView doesn't work
    primarykey
    data
    text
    <p>I'm trying to call another <code>Fragment</code> when I click on list item but it doesn't work, I'm using slider menu and the items of <code>ListView</code> are options inside the slider menu. What am I doing wrong?</p> <pre><code>public class MenuNetimoveis_Fragments extends ListFragment { private ListView listView; String[] itensMenu = new String[] { " Imóveis no mapa", "Favoritos", "Agências", "Dicas para Alugar", "Alugar meu imóvel", "Sobre" }; int[] imagens = new int[]{ R.drawable.map_marker, R.drawable.star, R.drawable.house, R.drawable.coffee, R.drawable.pricetag, R.drawable.pricetag }; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.list, null); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ImageView tv = new ImageView(getActivity()); Drawable dw = getResources().getDrawable(R.drawable.menu_netimoveis_locacao); tv.setImageDrawable(dw); getListView().addHeaderView(tv); crateListView(); } private void crateListView(){ List&lt;HashMap&lt;String,String&gt;&gt; aList = new ArrayList&lt;HashMap&lt;String,String&gt;&gt;(); for(int i=0;i&lt;6;i++){ HashMap&lt;String, String&gt; hm = new HashMap&lt;String,String&gt;(); hm.put("txt", itensMenu[i]); hm.put("imagens", Integer.toString(imagens[i]) ); aList.add(hm); } String[] from = { "txt","imagens" }; int[] to = { R.id.text,R.id.imagemview}; SimpleAdapter adapter = new SimpleAdapter(getActivity().getBaseContext(), aList, R.layout.list_row, from, to); setListAdapter(adapter); } @Override public void onListItemClick(ListView lv, View v, int position, long id) { Fragment newContent = null; switch (position) { case 0: newContent = new Menu_DicasParaAlugar(); break; case 1: break; } if (newContent != null) switchFragment(newContent); } // the meat of switching the above fragment private void switchFragment(Fragment fragment) { if (getActivity() == null) return; if (getActivity() instanceof FragmentChangeActivity) { FragmentChangeActivity fca = (FragmentChangeActivity) getActivity(); fca.switchContent(fragment); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload