Reputation: 157
I am developing a survey like application. I am wondering is it possible to change a view without having to make an activity for each. For example I would have one question that asks a user something then there is a next button which would load the next question. Don't worry about where the questions are coming from..
Is there any good tutorials on how to use Monodrois View.cs classes?
Thanks.
Upvotes: 1
Views: 412
Reputation: 2978
Off course you are able to change layout without creating new Activity
.
I think View classes will not help you to solve your problem. View class designed simply for creating custom controls(Views).
You can do this in such way:
protected override void OnCreate(Bundle bundle)
{
CreateViewForQuestion(QuestionService.GetFirstGuestion());
}
void CreateViewForQuestion(QuestionModel question)
{
SetContentView(question.Layout);// or any else layouts storage
//initialize different controls
FindViewById<Button>(Resources.Id.BtnNextQuestion).Click+=
delegate {
//Save result
CreateViewForQuestion(QuestionService.GetNextQuestion(question));
};
}
Code is very generic but you can get main idea of resolving your problem.
Upvotes: 2