Android中使用XML文件配置OptionMenu
来源:互联网 发布:淘宝规则大全 编辑:程序博客网 时间:2024/05/29 02:37
标签:Android SDK
[1].[代码] menu.xml 跳至 [1] [2] [3]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
menu
xmlns:Android
=
"http://schemas.android.com/apk/res/android"
>
<
item
Android:id
=
"@+id/close"
android:title
=
"Close"
Android:orderInCategory
=
"3"
android:icon
=
"@drawable/eject"
/>
<
item
Android:id
=
"@+id/no_icon"
android:orderInCategory
=
"2"
Android:title
=
"Sans Icon"
/>
<
item
Android:id
=
"@+id/disabled"
android:orderInCategory
=
"4"
Android:enabled
=
"false"
android:title
=
"Disabled"
/>
<
group
Android:id
=
"@+id/other_stuff"
android:menuCategory
=
"secondary"
Android:visible
=
"false"
>
<
item
Android:id
=
"@+id/later"
android:orderInCategory
=
"0"
Android:title
=
"2nd-To-Last"
/>
<
item
Android:id
=
"@+id/last"
android:orderInCategory
=
"1"
Android:title
=
"Last"
/>
</
group
>
<
item
Android:id
=
"@+id/submenu"
android:orderInCategory
=
"3"
Android:title
=
"A Submenu"
>
<
menu
>
<
item
Android:id
=
"@+id/non_ghost"
android:title
=
"Non-Ghost"
Android:visible
=
"true"
android:alphabeticShortcut
=
"n"
/>
<
item
Android:id
=
"@+id/ghost"
android:title
=
"A Ghost"
Android:visible
=
"false"
android:alphabeticShortcut
=
"g"
/>
</
menu
>
</
item
>
</
menu
>
[2].[代码] main.xml 跳至 [1] [2] [3]
1
2
3
4
5
6
7
8
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
LinearLayout
xmlns:Android
=
"http://schemas.android.com/apk/res/android"
Android:orientation
=
"vertical"
Android:layout_width
=
"fill_parent"
Android:layout_height
=
"fill_parent"
>
</
LinearLayout
>
[3].[代码] XmlMenuAcitvity.java 跳至 [1] [2] [3]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package
yyl.xmlMenu;
import
Android.app.Activity;
import
Android.os.Bundle;
import
Android.view.ContextMenu;
import
Android.view.ContextMenu.ContextMenuInfo;
import
Android.view.Menu;
import
Android.view.MenuInflater;
import
Android.view.View;
public
class
XmlMenuAcitvity
extends
Activity {
/** Called when the activity is first created. */
@Override
public
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public
boolean
onCreateOptionsMenu(Menu menu) {
//将页面定义的menu配置到到activity中
new
MenuInflater(getApplication())
.inflate(R.layout.menu, menu);
return
super
.onCreateOptionsMenu(menu);
}
}
0 0
- Android中使用XML文件配置OptionMenu
- Android中使用XML文件配置OptionMenu
- Android中使用XML文件配置OptionMenu
- Android中OptionMenu使用
- Android 中 OptionMenu 使用
- android中OptionMenu和ContextMenu创建
- Android之OptionMenu菜单的使用
- android中如何使用配置config.xml
- android中string.xml文件的使用
- Android中XML文件的使用
- android中xml文件的使用
- android中使用SAX读取XML文件
- android中string.xml文件的使用
- android中string.xml文件的使用
- android中xml文件的使用详解
- android中使用SAX解析xml文件
- Android 中使用Pull解析XML文件
- Android中使用XmlPullParse解析xml文件
- nyoj 458
- ios开发调试技巧-1
- 使用高性能的数据库连接池管理工具BoneCP
- 关于java的字节码
- 【POJ3658】【USACO 2008 Jan Gold】 2.Artificial Lake人工湖 单调栈
- Android中使用XML文件配置OptionMenu
- iOS 开发百问(7)
- 滑动选择日期
- 反射的基本使用实例
- python 邮件发送
- 第十九周oj刷题:成绩分类
- GDI+截屏
- java urlrewrite
- J2SE--关于Java占用内存