어떻게하면 작업 표시 줄에 메인 메뉴를 만들 수 있으며 하드웨어 버튼을 클릭 할 때 열리는 "옵션"메뉴를 만들 수 있습니까?메뉴 및 옵션 메뉴 함께하기
Whatsapp와 유사합니다.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.calendar, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_legend) {
// Open dialog
} else if(id == R.id.action_settings) {
startActivity(new Intent(this, SettingsActivity.class));
} else if(id == R.id.action_add) {
startActivity(new Intent(this, AddActivity.class));
}
return super.onOptionsItemSelected(item);
}
@Override
public boolean onKeyDown(int keycode, KeyEvent e) {
switch(keycode) {
case KeyEvent.KEYCODE_MENU:
// Here open the options menu
return true;
}
return super.onKeyDown(keycode, e);
}
:이 아바타, 이름과 아이콘이있는 액션 바는 그리고 당신이 누르면 "메뉴"버튼을, 그것과 다른 메뉴가 나타납니다이 내 실제 코드 등
을 "연락처, 미디어, 검색"
하드 메뉴 키가있는 구형 장치를 보면 해당 키를 누르면 메뉴가 활성화/비활성화됩니다. 특별한 일은 할 필요가 없습니다. –
하지만이 버튼은 액션 바에있는 메인 메뉴이며 하드웨어 버튼 클릭으로 다른 것을 보여주고 싶습니다. 나는 두 가지 메뉴를 부 풀릴 수 있다고 생각하지 않는다. – Grork