2013-06-22 3 views
0

메뉴 화면에 3 개의 버튼이 있으며 3 가지 다른 활동을 연결하고 싶습니다. 모든 단일 버튼은 다른 활동을 확장합니다. 어떻게 할 수 있습니까? 1 개의 수업과 활동이있을 때 아무런 문제가 없지만 3시에는 문제가됩니다. 고맙습니다.3 가지 다른 버튼과 3 가지 버튼을 연결하는 방법은 무엇입니까?

+0

어떻게 확장하거나 할 일의 (a) 뭔가 하나를 게시에 대한 (b)에 거의 도움을 작동 뭔가를 ? 이렇게하면 사람들이 당신을 도울 수 있습니다. –

답변

0

당신이 MainActivity, SettingsActivityProfileActivity라는 세 가지 활동을 가정하면, 당신은 할 수 있습니다 :

@Override 
public boolean onOptionsItemSelected(MenuItem item){ 
Intent intent; 
    Class<?> cls; 
    switch(item.getItemId()){ 
    case R.id.main: 
     cls = MainActivity.class; 
     break; 
    case R.id.settings: 
     cls = ScheduleView.class; 
     break; 
    case R.id.profile: 
     cls = UserPrefsActivity.class; 
     break; 
    default: 
     Log.d(this.getClass().getSimpleName(),"Should not happen"); 
     return false; 
    } 
    intent = new Intent(getApplicationContext(), cls); 
    startActivity(intent); 
    return true; 
} 
관련 문제