Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to do multiple intents?
    text
    copied!<p>I'm trying to do 3 intents to start a new activity, however I find that I always get an error. I'm putting my code onto main.java code:</p> <pre><code>public class Main extends Activity { Button service; Button gallery; Button contact; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); service = (Button)findViewById(R.id.Services); service.setOnClickListener(new View.OnClickListener() { }); gallery = (Button)findViewById(R.id.Gallery); gallery.setOnClickListener(new View.OnClickListener() { }); contact = (Button)findViewById(R.id.Contact); contact.setOnClickListener(new View.OnClickListener() { }); public void onClick (View v) { // Inflate the menu; this adds items to the action bar if it is present. Intent intent = new Intent (Main.this, servicesActivity.class); startActivity(intent); } public void onClick1 (View v) { Intent intent1 = new Intent (Main.this, galleryActivity.class); startActivity(intent1); } public void onClick2 (View v) { Intent intent2 = new Intent (Main.this, contactActivity.class); startActivity(intent2); } } } </code></pre> <p>I have tried different ways and even putting brackets in different places. also I have been searching on the internet for weeks and found nothing that work with more than 1. I'm getting errors on <em>OnClick and new View.OnClickListener()</em>. I have got one working which is why I tried the same code with 3 buttons. Basically I have 3 buttons on main activity.xml. All I want to do is:</p> <pre><code>&gt;'button1 &gt;goes&gt; activity1' &gt;'button2 &gt;goes&gt; activity2' &gt;'button3 &gt;goes&gt; activity3' </code></pre> <p>Please give me any hints or tips as I'm new to Android dev.</p>
 

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