I want to use fragment in my activity so that on button press it will update the textView. I am storing that data in ArrayList.I want to show that data one by one in text view on button press. If ArrayList contains five data then I want to update the text in text view five times using fragment
@Override
protected void onPostExecute(Void args) {
//aero();
TextView txtview = (TextView) findViewById(R.id.question);
questionList = new ArrayList<String>();
if (!questionList.contains(mcq.get(currentPosition).getPs())
) {
questionList.add(mcq.get(currentPosition).getPs());
txtview.setText(mcq.get(currentPosition).getPs().toString());
Button btnnext = (Button) findViewById(R.id.next);
btnnext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
currentPosition = currentPosition + 1;
if (currentPosition < mcq.size()) {
txtView.setText(mcq.get(currentPosition).getPs());
}
}
});
Right now only first data is displayed in the text view.