Note that there are some explanatory texts on larger screens.

plurals
  1. PO2 buttons in my android layout, only 1 will work
    text
    copied!<p>In the android sdk, I have programmed 2 buttons to bring me to 2 different layouts. However, only the first one I have programmed will work, while the second one will do completely nothing. I will provide the code if you can catch any things I missed, please tell me what you think. This is one of my first applications to run on android, so try to explain your suggestion as simple as you could.</p> <p>Code:</p> <pre><code> public class MainActivity extends Activity { private final String T = "Settings"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); settingsButton(); } private final String T2 = "ManualAdd"; protected void onCreate1(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); feederButton(); } private void settingsButton() { Button messageButton = (Button) findViewById(R.id.Settings); View.OnClickListener myListener = new View.OnClickListener() {@ Override public void onClick(View v) { Log.i(T, "You clicked the settings button!"); startActivity(new Intent(MainActivity.this, SettingsActivity.class)); } }; messageButton.setOnClickListener(myListener); } private void feederButton() { Button feedButton = (Button) findViewById(R.id.AddFeeder); View.OnClickListener my2ndListener = new View.OnClickListener() { public void onClick(View v) { Log.i(T2, "You clicked the add button!"); startActivity(new Intent(MainActivity.this, ManualAdd.class)); } }; feedButton.setOnClickListener(my2ndListener); } } </code></pre>
 

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