Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>adding to previous answers: you can create button in your xml layout as much as you want, this doesn't have relation with the oncreate method.</p> <p>all you have to do to use these button in your mainactivity java file is to initialize it like this:</p> <pre><code> Button name=(Button)findViewById(R.id."button name or id in your xml file"); </code></pre> <p>you can press "Ctrl plus space" in the same time after "R.id." to get you all the objects you have created in the xml file and choose what you want. no to switch to another activity do this in your onclicklistener.</p> <pre><code> startActivity(new Intent("yourcurrent activity".this, "the name of activity you want to switch to".class)); </code></pre> <p>which in this case is:</p> <pre><code> startActivity(new Intent(MainActivity.this,SecondScreen.class)); </code></pre> <p>then go to you AndroidManifest file and type this inside the application part...you can type it at the very end of the application part.</p> <pre><code> &lt;activity android:name=".the name of your second activity"/&gt; </code></pre> <p>which in your case is:</p> <pre><code> &lt;activity android:name=".Secondscreen"/&gt; </code></pre> <p>you have to do this whenever creating a new activity.</p> <p>then in your second activity you should tell what xml file you are viewing so you should do this in the second class activity, just like default of the mainacitivty once you have created it.</p> <pre><code> @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout."name of your xml file you want to view"); </code></pre> <p>and i suggest you have a look at this tutorial: <a href="http://www.youtube.com/watch?v=q6-4E1JGT_k" rel="nofollow">http://www.youtube.com/watch?v=q6-4E1JGT_k</a></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