검색결과 리스트
2012/12/29에 해당되는 글 2건
- 2012.12.29 View PopupMenu
- 2012.12.29 View/Full Screen Modes / Hide Navigation
글
API 11에서 제공하는 팝업 메뉴
메뉴에 서브메뉴가 가능해서 기존 노출되는 팝업 메뉴가 사라지고 서브메뉴가 나온다.
public void onPopupButtonClick(View button) {
PopupMenu popup = new PopupMenu(this, button);
popup.getMenuInflater().inflate(R.menu.popup, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(PopupMenu1.this, "Clicked popup menu item " + item.getTitle(),
Toast.LENGTH_SHORT).show();
return true;
}
});
popup.show();
}
메뉴 xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/search"
android:icon="@android:drawable/ic_menu_search"
android:title="@string/popup_menu_search" />
<item android:id="@+id/add"
android:icon="@android:drawable/ic_menu_add"
android:title="@string/popup_menu_add" />
<item android:id="@+id/edit"
android:icon="@android:drawable/ic_menu_edit"
android:title="@string/popup_menu_edit">
<menu>
<item android:id="@+id/share"
android:icon="@android:drawable/ic_menu_share"
android:title="@string/popup_menu_share" />
</menu>
</item>
</menu>
'Android > ApiDemo_Graphic' 카테고리의 다른 글
View/Full Screen Modes / Hide Navigation (0) | 2012.12.29 |
---|
설정
트랙백
댓글
글
화면에 동적으로 제어하는 코드로써
특징적인 것은 Navigation을 숨기는 코드가 들어 있다.
네비게이션을 옮기는 설정은 SYSTEM_UI_FLAG_HIDE_NAVIGATION인데, 아래와 같은 사항에 주의해서 사용해야 하네요.
"View has requested that the system navigation be temporarily hidden. This is an even less obtrusive state than that called for by SYSTEM_UI_FLAG_LOW_PROFILE; on devices that draw essential navigation controls (Home, Back, and the like) on screen, SYSTEM_UI_FLAG_HIDE_NAVIGATION will cause those to disappear. This is useful (in conjunction with the FLAG_FULLSCREEN and FLAG_LAYOUT_IN_SCREEN window flags) for displaying content using every last pixel on the display. There is a limitation: because navigation controls are so important, the least user interaction will cause them to reappear immediately."
This flag will allow to take over the entire screen, unlike Honeycomb where there was always a navigation bar at the bottom with room for the Back, Home, and Recents button. Unfortunately it won't work for games because of the last sentence.
'Android > ApiDemo_Graphic' 카테고리의 다른 글
View PopupMenu (0) | 2012.12.29 |
---|
RECENT COMMENT