2014-01-24 93 views
-2
@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    // Handle presses on the action bar items 
    switch (item.getItemId()) { 
     case R.id.action_settings: 

(我必須在這裏我寫什麼該應用程序將打開另一個活動?)我怎樣才能使這將打開另一個佈局?

回答

0
switch (item.getItemId()){ 
    case R.id.action_settings: 
     Intent i = new Intent(this, AnotherActivity.class); 
     startActivity(i); 
     break; 
} 
0

寫打開一個新的活動 -

@Override 
public boolean onOptionsItemSelected(MenuItem item) 
{ 
    // Handle presses on the action bar items 
    switch (item.getItemId()) 
    { 
     case R.id.action_settings: 
Intent intent = new Intent(YourCurrentActivity.this, NextActivity.class); 
startActivity(intent); 
+0

@divjad ---不要忘了在manifest.xml中添加「NextActivity」 –

相關問題