Note that there are some explanatory texts on larger screens.

plurals
  1. POInflated View doesn't catch onClick event
    primarykey
    data
    text
    <p>I have an template view it looks like ;</p> <p>template.xml :</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/contentLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/view_background" android:gravity="center_vertical" tools:context=".MainActivity" &gt; &lt;Button android:id="@+id/btnMultiple" android:layout_width="0dp" android:layout_height="150dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_weight="1" android:background="@drawable/button_backgroundblue" android:onClick="btnMultiple_clicked" android:tag="4" android:text="@string/mc_abcd" android:textColor="@drawable/button_textcolor" android:textSize="@dimen/h2" /&gt; </code></pre> <p></p> <p>I'm creating this view programmatically and then i'm adding this View into ViewFlipper as like ;</p> <p>activity_main.java</p> <pre><code>public void btnCreateView_clicked(View view) { ViewFlipper viewFlipper = (ViewFlipper)findViewById(R.id.flipper); View myView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.template, viewFlipper, false); viewFlipper.addView(myView); viewFlipper.showNext(); // Showing lastly created myView successfully. } </code></pre> <p>Also my activity has public function as like ;</p> <p>activity_main.java</p> <pre><code> public void btnMultiple_clicked(View view) { //Save the world ! } </code></pre> <p>When i press btnCreateView button from first view it's successfully creating template (myView) and then adding it into ViewFlipper. When i click btnMultiple i'm getting error and my application crashes ; "Could not find a method btnMultiple_clicked(View) in the activity class android.app.Application for onClick handler on view class android.widget.Button with id 'btnMultiple'" i'm sure there is existing method btnMultiple_clicked(View).</p> <p>PS! If i add listener to btnMultiple programmatically it's gonna work but i wonder why "android:onClick="btnMultiple_clicked"" doesn't work ?</p>
    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