0

I am making an app that takes in user's answers sums them and produces a score. Each screen is a question. How do I allow for a new screen activity to show after each question is answered? For example, one screen would be one question, then when that question is answered, the next screen is a new question, etc. How do I do this?

user3008456
  • 35
  • 2
  • 6

1 Answers1

1

INTENTS and CHANGING ACTIVITIES

http://developer.android.com/guide/components/intents-filters.html -- Please see the first paragraph of this page.

http://developer.android.com/reference/android/content/Intent.html

Explanation

If I understand your question correctly you are attempting to change activities through an action on your app. This is typically done using Intents. I highly recommend you review the data on Intents however below you can find a very brief example of changing intents based on a button click.

public class Splash extends Activity {
Button btnContinue;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash_screen);

    btnContinue = (Button) findViewById(R.id.btnCrows);
    btnContinue.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(Splash.this, MainActivity.class));
        }
    });
}

While this is not a very "complete" or in-depth example it is more than enough to get you started. As you can see we are using the startActivity() method to actually run the intent where we reference both the activity we are on as well as where we would like to go. The API docs referenced in this post also explain this very well.

basic
  • 3,348
  • 3
  • 21
  • 36