I am new to Android application development, and I've been working on a simple FlashLight app that switches between various colors on the screen. The initial activity draws up a layout with only 2 buttons, labeled Green and Blue. I've installed Click Listeners on both buttons and set intents on them both in order for each to load it's corresponding activity, but when I run the app I can only go from the first view to ONE of the other views(Green OR Blue, but not both). I want to be able to choose EITHER button and load the next activity, but I'm a bit lost. Maybe create a boolean that determines which button the user clicked? IDK. This may sound a bit confusing as I'm not good at describing technical things like this, but here's my code below.
package com.jbsoft.SimpleFlashlight; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.*; import android.widget.Button; import android.widget.Toast; public class SimpleFlashLightActivity extends Activity { Button GreenButton; Button BlueButton; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); BlueButton = (Button) findViewById(R.id.bluebutton); BlueButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent blueintent = new Intent(SimpleFlashLightActivity.this, BlueFlashLightActivity.class); startActivity(blueintent); Toast.makeText(v.getContext(), "SWITCH COLOR!", Toast.LENGTH_LONG); GreenButton = (Button) findViewById(R.id.bluebutton); GreenButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent greenintent = new Intent( SimpleFlashLightActivity.this, GreenFlashLightActivty.class); startActivity(greenintent); } }); } }); } public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater mi = getMenuInflater(); mi.inflate(R.menu.list_menu, menu); return true; } }