Note that there are some explanatory texts on larger screens.

plurals
  1. PODifficulties with android on click listener
    primarykey
    data
    text
    <p>firstly I have to write that I have just started my adventure with android, I'm building simple menu and as far as I have about and exit button working :), I've tried with start button but it doesn't listen at all, If You have any suggestions what to do with it I would more than happy :)</p> <p>main activity:</p> <pre><code>public class MainActivity extends Activity implements OnClickListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); View startButton = findViewById(R.id.start_button); startButton.setOnClickListener(this); View whereButton = findViewById(R.id.where_button); whereButton.setOnClickListener(this); View aboutButton = findViewById(R.id.about_button); aboutButton.setOnClickListener(this); View exitButton = findViewById(R.id.exit_button); exitButton.setOnClickListener(this); } public void onClick(View v) { switch (v.getId()) { case R.id.about_button: Intent i = new Intent(this, About.class); startActivity(i); break; case R.id.exit_button: finish(); break; case R.id.start_button: i = new Intent(this, Start.class); startActivity(i); break; } } </code></pre> <p>Strings.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;string name="app_name"&gt;City Inspector&lt;/string&gt; &lt;string name="main_title"&gt;Ldz Inspector&lt;/string&gt; &lt;string name="start_title"&gt;Profile&lt;/string&gt; &lt;string name="start_label"&gt;START&lt;/string&gt; &lt;string name="where_label"&gt;WHERE AM I?&lt;/string&gt; &lt;string name="option_label"&gt;OPTIONS&lt;/string&gt; &lt;string name="about_label"&gt;ABOUT&lt;/string&gt; &lt;string name="create_label"&gt;CREATE PROFILE&lt;/string&gt; &lt;string name="browse_label"&gt;BROWSE MAP&lt;/string&gt; &lt;string name="exit_label"&gt;EXIT&lt;/string&gt; &lt;string name="about_text"&gt;\ about program things &lt;/string&gt; &lt;/resources&gt; </code></pre> <p>start.java</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.start); } } </code></pre> <p>start.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@color/background" android:layout_height="fill_parent" android:layout_width="fill_parent" android:padding="20dip" android:orientation="horizontal" &gt; &lt;LinearLayout android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_gravity="center" &gt; &lt;TextView android:text="@string/start_title" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center" android:layout_marginBottom="25dip" android:textSize="24.5sp" /&gt; &lt;Button android:id="@+id/Create_Profile" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/create_label" /&gt; &lt;Button android:id="@+id/Browse_Map" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/browse_label" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>!!EDIT:</p> <p>Sorry I knew I forgot to post something :), here is the AndroidManifest :)</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="menu.dot" android:versionCode="1" android:versionName="1.0"&gt; &lt;application android:label="@string/app_name" android:icon="@drawable/icon"&gt; &lt;activity android:name="MainActivity" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".About"&gt; android:label="@string/about_title" android:theme="@android:style/Theme.Dialog" &gt; &lt;/activity&gt; &lt;activity android:name=".Exit"&gt; andorid:label="@string/exit_title"&gt; &lt;/activity&gt; &lt;activity android:name=".Start"&gt; andorid:label="@string/start_title"&gt; &lt;/activity&gt; /application&gt; &lt;/manifest&gt; </code></pre> <p>Please check the start.xml edition</p> <p>main.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@color/background" android:layout_height="fill_parent" android:layout_width="fill_parent" android:padding="20dip" android:orientation="horizontal" &gt; &lt;LinearLayout android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_gravity="center" &gt; &lt;TextView android:text="@string/main_title" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center" android:layout_marginBottom="25dip" android:textSize="24.5sp" /&gt; &lt;Button android:id="@+id/start_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/start_label" /&gt; &lt;Button android:id="@+id/where_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/where_label" /&gt; &lt;Button android:id="@+id/option_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/option_label" /&gt; &lt;Button android:id="@+id/about_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/about_label" /&gt; &lt;Button android:id="@+id/exit_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/exit_label" /&gt; &lt;/LinearLayout&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