How can I go from one page to another without using Intent?

I want to create a quiz based application that consists of 14 questions.

Can someone tell me how I need to go from one question to another by clicking on the next button. If I use Intent , then I'm afraid that I will create 14 Activities

I also do not think that this is also a program procedure.

+6
source share
6 answers

You can stay in the same Activity and follow the question.

You can use TextSwitcher to add fade animation to / fade out when replacing question text.

+3
source

You can click to simply refresh the text of the questions to be the next question.

  nextButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { questionTextView.setText(questionTwo); } }); 
+3
source

Change the text of your text views where the questions are.

 @Override protected void onCreate(Bundle savedInstanceState) { Button nextButton = (Button) findViewById(R.id.yourButtonId); TextView questionTextView = (TextView) findViewById(R.id.yourTextViewId); nextButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { questionTextView.setText("Your Next Question"); } }); } 
+1
source

A snippet is part of the user interface of an application or behavior that can be placed in an Activity.

  • Has its own life cycle;
  • Gets its own input events;
  • It can be added or removed during operation;

Believe me, this is the best method. I was introduced to fragments having an application with quotes. List of quotes on the left and quotation marks that were changed on the left when the author was selected.

+1
source

I use android.widget.ViewFlipper , which contains views in which one view contains a TextView (question) and "input control" for the answer (selectboxes, date / time widget, radio group, etc.).

0
source

Source: https://habr.com/ru/post/893329/


All Articles