Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid onTouch Activity New XML File Error
    primarykey
    data
    text
    <p>I have 3 XML files. The first one is for main activity. It has one button. When I touch this button, it works and it sends me to second XML file. Also the second screen has a button. Now, I want to make same operation here and I wanna go third XML file. But it doesn't work. </p> <p>I did same procedure for all buttons. I can't find that where is my fault.</p> <p><code>MainPageActivity</code>:</p> <pre><code>public class MainPageActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_page); ImageButton b1 = (ImageButton) findViewById(R.id.button_compare); ImageButton b2 = (ImageButton) findViewById(R.id.button_find); b1.setOnTouchListener(new View.OnTouchListener(){ @Override public boolean onTouch(View comparePage, MotionEvent event) { setContentView(R.layout.compare_pagee); return true; } }); b2.setOnTouchListener(new View.OnTouchListener(){ @Override public boolean onTouch(View findPage, MotionEvent event) { setContentView(R.layout.find_page); return true; } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main_page, menu); return true; } } </code></pre> <p><code>activity_main_page.xml</code>:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainPageActivity" android:id="@+id/mainActivity" &gt; &lt;ImageButton android:id="@+id/button_compare" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="false" android:layout_alignParentTop="false" android:adjustViewBounds="true" android:scaleType="center" android:src="@drawable/compare" /&gt; &lt;ImageButton android:id="@+id/button_find" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_marginLeft="69dp" android:adjustViewBounds="true" android:src="@drawable/find" /&gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:gravity="center_vertical|center_horizontal" android:text="Tap the top to Compare!" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;TextView android:id="@+id/textView2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/button_compare" android:gravity="center_vertical|center_horizontal" android:text="Tap the bottom to Find!" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p><code>Compare</code>:</p> <pre><code>public class Compare extends Activity{ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.compare_pagee); ImageButton b3 = (ImageButton) findViewById(R.id.compareButton); b3.setOnTouchListener(new View.OnTouchListener(){ @Override public boolean onTouch(View comparePage, MotionEvent event) { setContentView(R.layout.compare_pagee); return true; } }); } } </code></pre> <p><code>compare_pagee.xml</code>:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/backgroundwallpaper" android:clickable="true" android:orientation="vertical" tools:context=".Compare" &gt; &lt;Spinner android:id="@+id/spinner2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /&gt; &lt;Spinner android:id="@+id/spinner3" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /&gt; &lt;Spinner android:id="@+id/spinner5" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /&gt; &lt;ImageButton android:id="@+id/compareButton" android:layout_width="139dp" android:layout_height="74dp" android:src="@drawable/comparebutton" /&gt; &lt;Spinner android:id="@+id/spinner6" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /&gt; &lt;Spinner android:id="@+id/spinner4" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /&gt; &lt;Spinner android:id="@+id/spinner1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /&gt; &lt;/LinearLayout&gt; </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