Note that there are some explanatory texts on larger screens.

plurals
  1. POClickable listview in fragment
    primarykey
    data
    text
    <p>I am trying to create a simple clickable listview in a fragment. (not a listfragment) So when you click a item it goes to a new detailpage about that item.</p> <p>I got the listview working but I cant seem to figure out how to get the items clickable. I am very new to android programming..</p> <p>My application is seperated in 4 tabs, this is one of them. </p> <p>The question is: How do I make items in a listview (in a fragment) clickable? </p> <p>My fragment class:</p> <pre><code> import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView; public class BiblioFragment extends Fragment { final String[] items = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2" }; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_biblio, container, false); ListView list = (ListView)view.findViewById(R.id.listView1); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(getActivity(), android.R.layout.simple_list_item_1, items); list.setAdapter(adapter); return view; } </code></pre> <p>}</p> <p>XML</p> <pre><code>&lt;ListView android:id="@+id/listView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" &gt; &lt;/ListView&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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