views:

20

answers:

1

I want to create a page with X questions (the questions are stored in a database and I read them), headline and buttons at the end.

When the user clicks on one question than the question should transform into a dialog where the user can modify the question, however the other questions above and beneath it should still display the same way.

The way ListActivity is used in the sample notepad application in the android documentation it seems like the class can only display multiple items of the same type.

Is there a straightforward way to go about this problem?

+1  A: 

I should tell you that I don't like your solution as an user. I would prefer to chose from a list and having an edit activity after a click. That's the default approach I've seen in every android app and it will be also easier for you.

If you still want to do what you explained I would try do this:

  • Create a ListView
  • Create a class QuestionOrDialog
  • Create an Adapter that extends from ArrayAdapter

Override getView doing something like:

QuestionOrDialog aQuestionOrDialog =  getItem(position);

if ( aQuestionOrDialog.showDialog() ) {
  return mInflater.inflate(R.layout.dialog, parent, false);
} else {
  view = mInflater.inflate(R.layout.question, parent, false);
  TextView question = (TextView) view.findViewById(R.id.question);
  question.setText(aQuestionOrDialog.getQuestion());
}
  • On the OnClick you will have to do a getItem() and set that it was clicked.
  • Tell the listView that it's item have changed.

Hope it works.

Macarse