The code below works great in that GameView comes up with a simple
image. After user has selected the one and only menu option, I get
the TextView with "Hello, Earth" as appropriate.
The problem I have is if in onCreate(), I setContentView(TextView)
and not GameView. In this case, user is shown a "Hello, World"
first. After the user has selected the menu option, GameView is set
as the active view and is
active, but I see no images. The screen is simply blank...any idea
anyone?
Am I using setContentView properly?
Thanks...
public class MainActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, World");
//setContentView(tv);
setContentView(new GameView(this));
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
menu.add(0, MENU_ONE_PLAYER, 0,
R.string.MAIN_MENU_ONE_PLAYER);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case MENU_ONE_PLAYER:
TextView tv = new TextView(this);
tv.setText("Hello, Earth");
setContentView(tv);
//setContentView(new GameView(this));
return true;
}
return false;
}
private static final int MENU_ONE_PLAYER = 1;
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---