This may seem like a dumb question, but do you need an xml and class for every activity aka. page you want in an app. The more activities I have, the slower the emulator is. I want to create a reference app much like Human Japanese, and was wondering how to create multiple pages in an app without creating multiple activities.
4 Answers
When I was creating my OSCAR 2011 app, I had this question. What I did was I passed a value along with Intend and received passed value in the activity class which initiated by the Intend. based on the value recieved I can call different values from string xml file.
this is how it is in the class where call originated.
case 0:
Intent bestactor = new Intent(MovieList.this,WinnerActivity.class);
bestactor.putExtra("ListCount", "one");
startActivity(bestactor);
break;
This is how I received and set the content
Bundle extras = getIntent().getExtras();
String data = extras.getString("ListCount");
if(data.equals("one"))
{
setContentView(R.layout.winner);
TextView txtWinnerList = (TextView) findViewById(R.id.txtWinnerList);
txtWinnerList.setText(R.string.actorintheleadingrole);
TextView txtNomineeList = (TextView) findViewById(R.id.txtNomineesList);
txtNomineeList.setText(R.string.nomineesactorinleadingrole);
}
else if(data.equals("two"))
{
setContentView(R.layout.winner);
TextView txtWinnerList = (TextView) findViewById(R.id.txtWinnerList);
txtWinnerList.setText(R.string.actorinasupportingrole);
TextView txtNomineeList = (TextView) findViewById(R.id.txtNomineesList);
txtNomineeList.setText(R.string.nomineesactorinasupportingrole);
}