Mamoon Saleem
Mamoon Saleem

Reputation: 13

Change text on Fragment on button click

I want to make a quiz app. So i want to change the question statement in fragment . How can i do that enter image description here

Upvotes: 1

Views: 221

Answers (4)

Arsalan Imtiaz
Arsalan Imtiaz

Reputation: 160

First you have to create QuestionType list with question, option1, option2, option3, option3, correct option. and on onclick button get question from list and change values for your radio group. Hope this will help you.

Upvotes: 2

Ankit
Ankit

Reputation: 135

Activity can call fragment method by acquiring a reference to the Fragment.

Call fragment like this-

transaction.add(R.id.fragment_container, myFragment, "myfragmentTag");

and by the help of fragment object you can call fragment method

myFragment.refreshQuestion();

You can also use the Interface to achieve this

Upvotes: 0

Hina Hussain
Hina Hussain

Reputation: 1

Store your question in ArrayList or some permanent storage like DB and then traverse list until last item is reached.Fetch value and set to textView by using setText() method.

Upvotes: 0

bhuvnesh pattnaik
bhuvnesh pattnaik

Reputation: 1463

Just make an ArrayList consisting Questions, answer and options.

On clicking Next Question, you just need to change the index of the arraylist.

When its the last question just change the text of button to Submit

Upvotes: 0

Related Questions