当前位置:首页 » 安卓系统 » android菜单

android菜单

发布时间: 2022-01-08 21:53:44

⑴ 关于Android中标题栏上的这个菜单

这个可以用官方的FloatingActionButton做出来,需要Demo的话请追问。

⑵ Android开发 怎么设置菜单选项固定在上方

很简单,微信用的不是系统menu,是自定义的,好像有点深奥,我简单解释下:
一般人创建菜单,都是使用oncreateoptionmenu或onpreparemenu,其实呢,还有两个方法,是用来确定menu的位置及显示的:onopenmenu和onCreatePanelView,你要是理解好了这俩接口就能实现你要的功能。

如果理解不了上面的方法,你就是使用自定义标题栏加popupwindow来实现,这个肯定能理解吧

⑶ Android中怎么实现底部菜单栏

自己顶一下——已经解决了问题,通过PopupWindow可以实现在界面任意位置弹出窗口,加上animation效果和menu一样。

⑷ android 菜单 怎么让同一个选项菜单在任何一个页面都能显示

单独写一个菜单的menu.xml,建一个Menu的类setcontentview(R.layout.menu),在Menu类里初始化控件,写监听事件等,在每个要弹菜单的类中new Menu();

⑸ Android 模拟器中按菜单Menu键弹出菜单项MenuItem,点击菜单项中的“退出”没反应

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
/*
*
* add()方法的四个参数,依次是:
*
* 1、组别,如果不分组的话就写Menu.NONE,
*
* 2、Id,这个很重要,Android根据这个Id来确定不同的菜单
*
* 3、顺序,那个菜单现在在前面由这个参数的大小决定
*
* 4、文本,菜单的显示文本
*/
//图标文件实现android系统自带的文件
menu.add(Menu.NONE, Menu.FIRST + 1, 1, "保存").setIcon(android.R.drawable.ic_menu_save);
menu.add(Menu.NONE, Menu.FIRST + 2, 2, "添加").setIcon(android.R.drawable.ic_menu_add);
// menu.add(Menu.NONE, Menu.FIRST + 3, 3, "删除").setIcon(android.R.drawable.ic_menu_delete);
// menu.add(Menu.NONE, Menu.FIRST + 4, 4, "发送").setIcon(android.R.drawable.ic_menu_send);
menu.add(Menu.NONE, Menu.FIRST + 5, 5, "帮助").setIcon(android.R.drawable.ic_menu_help);
menu.add(Menu.NONE, Menu.FIRST + 6, 6, "退出").setIcon(android.R.drawable.ic_menu_close_clear_cancel);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
// TODO Auto-generated method stub
switch(item.getItemId()){
case Menu.FIRST + 1:
Toast.makeText(WqtMainActivity.this, "保存菜单被点击了!", Toast.LENGTH_LONG).show();
//intent = new Intent(MenuActivity.this,Myhandler.class);
//startActivity(intent);
//overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
break;
case Menu.FIRST + 2:
Toast.makeText(WqtMainActivity.this, "添加菜单被点击了!", Toast.LENGTH_LONG).show();
break;
case Menu.FIRST + 3:
Toast.makeText(WqtMainActivity.this, "删除菜单被点击了!", Toast.LENGTH_LONG).show();
break;
case Menu.FIRST + 4:
Toast.makeText(WqtMainActivity.this, "发送菜单被点击了!", Toast.LENGTH_LONG).show();
//通知在状态栏显示的图标
//notification.icon = android.R.drawable.ic_lock_silent_mode_off;
//通知的内容
//notification.tickerText = "发送菜单被点击了!";
//通知时发出的声音
//notification.defaults = Notification.DEFAULT_SOUND;
//intent = new Intent(MenuActivity.this,mNotification.class);
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);
//pendindIntent = PendingIntent.getActivity(MenuActivity.this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
//notification.setLatestEventInfo(MenuActivity.this, "按钮", "发送按钮", pendindIntent);
//notificationManager.notify(913, notification);
break;
case Menu.FIRST + 5:
Toast.makeText(WqtMainActivity.this, "帮助菜单被点击了!", Toast.LENGTH_LONG).show();
break;
case Menu.FIRST + 6:
AlertDialog alertDialog = new AlertDialog.Builder(WqtMainActivity.this)
.setTitle("提示!")
.setIcon(R.drawable.ask)
.setMessage("您确定要退出系统吗?")
.setPositiveButton("确定",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
System.exit(0);
dialog.cancel(); //提示对话框关闭
}
})
.setNegativeButton("取消",
new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel(); //关闭对话框
}
}).create();
alertDialog.show();
break;
}
return super.onMenuItemSelected(featureId, item);
}

⑹ android开发中返回上一级菜单是怎么实现的

这个问题 提的太随意了吧。

菜单层级怎么来的?是你的页面还是系统菜单。
你的页面的话是 多个activity还是单个页面中layout层级,还是ActivityGroup中的?

⑺ android中怎么让menu菜单显示在屏幕左上角

用惯了Android的人在刚拿到iPhone的时候,总是会习惯性的用手指从状态栏往下拖一下,这都是给Notification闹的。
不过Notification也确实是1个不错的提示工具,不干扰正常的操作,事后还可以再翻看详细的内容,点击后还可以进入相关的画面查看更具体的内容。
今天我就以代码为主的形式来介绍Notification的使用,包括基本用法,自定义的View,以及更多的控制方法。
另一种Android中常用到的提示方法Toast的用法请参见《教程:在Android中使用Toast进行提示》
我们先看下Notification的几个主要组成部分:
Icon:不解释
Ticker Text:Notification刚出来的时候,在状态栏上滚动的字幕,如果很长,会自动分割滚动

Content Title:Notification展开后的标题
Content Text:Notification展开后的内容

Notification的一般用法
取得NotificationManager
private NotificationManager mNotificationManager;
mNotificationManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
创建Notification并且显示
//Notification的滚动提示
String tickerText = "My notification, It's a long text! Hello World desiyo?";
//Notification的图标,一般不要用彩色的
int icon = R.drawable.icon_02241_3;

//contentTitle和contentText都是标准的Notification View的内容
//Notification的内容标题,拖下来后看到的标题
String contentTitle="My notification";
//Notification的内容
String contentText="Hello World!";

//Notification的Intent,即点击后转向的Activity
Intent notificationIntent = new Intent(this, this.getClass());
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);

//创建Notifcation
Notification notification = new Notification(icon, tickerText, System.currentTimeMillis());
//设定Notification出现时的声音,一般不建议自定义
notification.defaults |= Notification.DEFAULT_SOUND;
//设定如何振动
notification.defaults |= Notification.DEFAULT_VIBRATE;
//指定Flag,Notification.FLAG_AUTO_CANCEL意指点击这个Notification后,立刻取消自身
//这符合一般的Notification的运作规范
notification.flags|=Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(this, contentTitle, contentText, contentIntent);
//显示这个notification
mNotificationManager.notify(HELLO_ID, notification);
这是最基本的应用,可以说除了找个合适的图标以外,其它都很简单。

使用自定义View的Notification
同Toast一样,我们也可以自已指定1个View来作为Notification展开后的显示内容,比如说在Android Market中下载的时候,Notification中会显示当前下载的进度,那么我们也来模拟1个这样的效果吧。
首先给出View的定义文件:notification_view_sample.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="3dp"
>
<ImageView android:id="@+id/notificationImage"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@android:drawable/stat_sys_download"
/>
<TextView android:id="@+id/notificationTitle"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_toRightOf="@id/notificationImage"
android:layout_alignParentRight="true"
android:paddingLeft="6dp"
android:textColor="#FF000000"
/>
<TextView android:id="@+id/notificationPercent"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/notificationImage"
android:paddingTop="2dp"
android:textColor="#FF000000"
/>
<ProgressBar android:id="@+id/notificationProgress"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/notificationTitle"
android:layout_alignLeft="@id/notificationTitle"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/notificationPercent"
android:paddingLeft="6dp"
android:paddingRight="3dp"
android:paddingTop="2dp"
style="?android:attr/progressBarStyleHorizontal"
/>
</RelativeLayout>
RelativeLayout的使用,可以参考:《教程:Android各种Layout特性和使用汇总(一)》

⑻ Android中menu菜单中的图片是怎么加进去的

给这个图片按钮添加一个事件, button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent=new Intent();
intent.setClass(当前Activity.this, 下一个Activity.class);
startActivity(intent);
当前Activity.finish();//关闭当前Activity
}
});
与普通按钮没有什么区别,一个就是有图片的,一个没有嘛,对它做事件都 一样,只不过显示效果不一样。

⑼ android点击menu键如何选择使用不同的菜单

什么叫【选择使用不同的菜单】?menu中最多显示8个,超过8个会自动添加一个【更多】,点击后显示其他的,你是问怎么设置菜单里面的内容还是什么?

热点内容
单片机android 发布:2024-09-20 09:07:24 浏览:760
如何提高三星a7安卓版本 发布:2024-09-20 08:42:35 浏览:660
如何更换服务器网站 发布:2024-09-20 08:42:34 浏览:308
子弹算法 发布:2024-09-20 08:41:55 浏览:285
手机版网易我的世界服务器推荐 发布:2024-09-20 08:41:52 浏览:813
安卓x7怎么边打游戏边看视频 发布:2024-09-20 08:41:52 浏览:158
sql数据库安全 发布:2024-09-20 08:31:32 浏览:90
苹果连接id服务器出错是怎么回事 发布:2024-09-20 08:01:07 浏览:503
编程键是什么 发布:2024-09-20 07:52:47 浏览:655
学考密码重置要求的证件是什么 发布:2024-09-20 07:19:46 浏览:479