當前位置:首頁 » 安卓系統 » 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個會自動添加一個【更多】,點擊後顯示其他的,你是問怎麼設置菜單裡面的內容還是什麼?

熱點內容
如何提高三星a7安卓版本 發布:2024-09-20 08:42:35 瀏覽:658
如何更換伺服器網站 發布:2024-09-20 08:42:34 瀏覽:305
子彈演算法 發布:2024-09-20 08:41:55 瀏覽:283
手機版網易我的世界伺服器推薦 發布:2024-09-20 08:41:52 瀏覽:811
安卓x7怎麼邊打游戲邊看視頻 發布:2024-09-20 08:41:52 瀏覽:157
sql資料庫安全 發布:2024-09-20 08:31:32 瀏覽:88
蘋果連接id伺服器出錯是怎麼回事 發布:2024-09-20 08:01:07 瀏覽:502
編程鍵是什麼 發布:2024-09-20 07:52:47 瀏覽:651
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:477
電腦主伺服器怎麼開機 發布:2024-09-20 07:19:07 瀏覽:728