2014-12-20 4 views
-1

메뉴에서 아무 것도 선택하면 목록의 선택 항목 아래에있는 모든 활동이 열리는 내 작업 표시 줄 바에서 드롭 다운 메뉴를 사용할 수 있습니다. 예를 들어 메뉴에서 그룹, 채팅, 친구, 설정을 선택할 수있는 경우 채팅을 선택하면 채팅 활동과 친구 및 설정이 열립니다. 응용 프로그램 만 선택하고 그 활동을 열 수 있도록드롭 다운 메뉴 - 모든 사례 선택

어떻게 그것을 만들 수 있습니다

MainActivity :

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.main, menu); 

    // Configure the search info and add any event listeners 
    MenuItem searchItem = menu.findItem(R.id.action_search); 
    SearchView searchView = (SearchView) MenuItemCompat 
      .getActionView(searchItem); 

    return true; 
} 

// Actionbar items 
@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    // Handle presses on the action bar items 
    switch (item.getItemId()) { 
     case R.id.action_search: 
      // searchView.OnQueryTextListener(); 
     case R.id.action_chat: { 
      // Starting the tabbed browsing for friends, indie/group chats 
      Intent i = new Intent(MainActivity.this, 
        GroupIndFriendActivity.class); 
      startActivity(i); 
     } 

     case R.id.action_alarms: { 
      Intent alerts = new Intent(MainActivity.this, 
        MyAlerts.class); 
      startActivity(alerts); 
     } 
     case R.id.action_favorite: 
      // openSettings(); 
     case R.id.action_favorite_specials: 
      // openSettings(); 

     case R.id.action_settings: { 
      Intent settings = new Intent(MainActivity.this, 
        ApplicationSettings.class); 
      startActivity(settings); 
     } 
     default: 
      return super.onOptionsItemSelected(item); 
    } 
} 

답변

0

당신은 그렇지 않으면 실행은 각 통해 떨어질 것이다, 당신의 case 블록 break 문 필요 그 다음에 case.

관련 문제