Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid view doesn't accept clicks
    primarykey
    data
    text
    <p>I add a listview via Java into @+id/View01. For some reason the items in the listview don't accept clicks. Does anybody have ideas about possible causes?</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:orientation="vertical" android:layout_height="fill_parent" android:background="@color/light_blue" &gt; &lt;Button android:text="@+id/Button01" android:id="@+id/Button01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge"/&gt; &lt;AbsoluteLayout android:id="@+id/Layout01" android:layout_width="fill_parent" android:orientation="vertical" android:layout_below="@+id/Button01" android:layout_above="@+id/Button02" android:layout_height="fill_parent"&gt; &lt;View android:id="@+id/View01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal" /&gt; &lt;ListView android:id="@+id/ListView02" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_horizontal"/&gt; &lt;/AbsoluteLayout&gt; &lt;Button android:text="@+id/Button02" android:id="@+id/Button02" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:textAppearance="?android:attr/textAppearanceLarge"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>If I change my code to the following the clicks work but the layout doesn't look the way I want.:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:orientation="vertical" android:layout_height="fill_parent" android:background="@color/light_blue" &gt; &lt;Button android:text="@+id/Button01" android:id="@+id/Button01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge"/&gt; &lt;View android:id="@+id/View01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/Button01" android:gravity="center_horizontal" /&gt; &lt;ListView android:id="@+id/ListView02" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/View01" android:gravity="center_horizontal" android:layout_above="@+id/Button02"/&gt; &lt;Button android:text="@+id/Button02" android:id="@+id/Button02" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:textAppearance="?android:attr/textAppearanceLarge"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>One of the functions involved:</p> <pre><code>protected void initiateExtraView(FillInput fillInput){ View extraView = fillInput.getExtraView(); ViewGroup parent = (ViewGroup) extraView.getParent(); int index = parent.indexOfChild(extraView); parent.removeView(extraView); extraView = fillInput.getLayoutInflater().inflate( R.layout.extrabuttonlistview, parent, false); parent.addView(extraView, index); fillInput.setExtraView(extraView); ListView extraButtonView = (ListView) extraView; fillInput.setExtraButtonListView(extraButtonView); ListAdapter adapter = new ExtraButtonAdapter(fillInput, this); fillInput.getExtraButtonListView().setAdapter(adapter); } </code></pre> <p>The function in the ExtraButtonAdapter that create the particular view that doesn't accept clicks:</p> <pre><code>private View getNewForm(int position, View convertView, ViewGroup parent) { View view = mInflater.inflate( R.layout.new_form_button, parent, false); View.OnClickListener listener = new View.OnClickListener() { public void onClick(View v) { Log.i(TAG, "Click on NewForm"); } }; view.setOnClickListener(listener); setNewFormView(view); return view; } </code></pre> <p>R.layout.extrabuttonlistview:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;ListView android:id="@+id/ListView01" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clickable="true" android:gravity="center_horizontal" android:layout_above="@+id/Button02"/&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.
    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