1. 安卓手機app界面的標題欄,導航欄,標簽欄指的是什麼_
狀態欄:是指手機左上最頂上,顯示中國移動、安全衛士、電量、網速等等,在手機的頂部。下拉就會出現通知欄。
標題欄:是指一個APP程序最上部的titleBar,從名字就知道它顯然就是一個應用程序一個頁面的標題了,例如打開QQ消息主頁,最上面顯示消息那一欄就是標題欄。
導航欄:是手機最下面的返回,HOME,主頁三個鍵,有些是一個按鈕。
2. android 怎麼實現點擊菜單在頂部和底部同時呼出不同的菜單選項
菜單是用戶界面中最常見的元素之一,使用非常頻繁,在Android中,菜單被分為如下三種,選項菜單(OptionsMenu)、上下文菜單(ContextMenu)和子菜單(SubMenu),以下說的是創建OptionsMenu
一、概述
public boolean onCreateOptionsMenu(Menu menu):使用此方法調用OptionsMenu。
public boolean onOptionsItemSelected(MenuItem item):選中菜單項後發生的動作。
public void onOptionsMenuClosed(Menu menu):菜單關閉後發生的動作。
public boolean onPrepareOptionsMenu(Menu menu):選項菜單顯示之前onPrepareOptionsMenu方法會被調用,你可以用此方法來根據打當時的情況調整菜單。
public boolean onMenuOpened(int featureId, Menu menu):單打開後發生的動作。
二、默認樣式
默認樣式是在屏幕底部彈出一個菜單,這個菜單我們就叫他選項菜單OptionsMenu,一般情況下,選項菜單最多顯示2排每排3個菜單項,這些菜單項有文字有圖標,也被稱作Icon Menus,如果多於6項,從第六項開始會被隱藏,在第六項會出現一個More里,點擊More才出現第六項以及以後的菜單項,這些菜單項也被稱作Expanded Menus。下面介紹。
1.main.xml
<?xmlversion="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextViewandroid:layout_width="wrap_content"
android:layout_height="wrap_content"android:text="請點擊Menu鍵顯示選項菜單"
android:id="@+id/TextView02"/>
</LinearLayout>
2。重載onCreateOptionsMenu(Menu menu)方法
重載onCreateOptionsMenu(Menu menu)方法,並在此方法中添加菜單項,最後返回true,如果false,菜單則不會顯示。
(Menumenu)
@Override
(Menumenu){
/*
*
*add()方法的四個參數,依次是:
*
*1、組別,如果不分組的話就寫Menu.NONE,
*
*2、Id,這個很重要,Android根據這個Id來確定不同的菜單
*
*3、順序,那個菜單現在在前面由這個參數的大小決定
*
*4、文本,菜單的顯示文本
*/
menu.add(Menu.NONE,Menu.FIRST+1,5,"刪除").setIcon(
android.R.drawable.ic_menu_delete);
//setIcon()方法為菜單設置圖標,這里使用的是系統自帶的圖標,同學們留意一下,以
//android.R開頭的資源是系統提供的,我們自己提供的資源是以R開頭的
menu.add(Menu.NONE,Menu.FIRST+2,2,"保存").setIcon(
android.R.drawable.ic_menu_edit);
menu.add(Menu.NONE,Menu.FIRST+3,6,"幫助").setIcon(
android.R.drawable.ic_menu_help);
menu.add(Menu.NONE,Menu.FIRST+4,1,"添加").setIcon(
android.R.drawable.ic_menu_add);
menu.add(Menu.NONE,Menu.FIRST+5,4,"詳細").setIcon(
android.R.drawable.ic_menu_info_details);
menu.add(Menu.NONE,Menu.FIRST+6,3,"發送").setIcon(
android.R.drawable.ic_menu_send);
returntrue;
}
3。為菜單項注冊事件
使用onOptionsItemSelected(MenuItem item)方法為菜單項注冊事件
(MenuItemitem)
@Override
(MenuItemitem){
switch(item.getItemId()){
caseMenu.FIRST+1:
Toast.makeText(this,"刪除菜單被點擊了",Toast.LENGTH_LONG).show();
break;
caseMenu.FIRST+2:
Toast.makeText(this,"保存菜單被點擊了",Toast.LENGTH_LONG).show();
break;
caseMenu.FIRST+3:
Toast.makeText(this,"幫助菜單被點擊了",Toast.LENGTH_LONG).show();
break;
caseMenu.FIRST+4:
Toast.makeText(this,"添加菜單被點擊了",Toast.LENGTH_LONG).show();
break;
caseMenu.FIRST+5:
Toast.makeText(this,"詳細菜單被點擊了",Toast.LENGTH_LONG).show();
break;
caseMenu.FIRST+6:
Toast.makeText(this,"發送菜單被點擊了",Toast.LENGTH_LONG).show();
break;
}
returnfalse;
}
4.完整代碼
packagecom.android.menu;
importandroid.app.Activity;
importandroid.os.Bundle;
importandroid.view.Menu;
importandroid.view.MenuItem;
importandroid.widget.Toast;
{
/**.*/
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
(Menumenu){
/*
*
*add()方法的四個參數,依次是:
*
*1、組別,如果不分組的話就寫Menu.NONE,
*
*2、Id,這個很重要,Android根據這個Id來確定不同的菜單
*
*3、順序,那個菜單現在在前面由這個參數的大小決定
*
*4、文本,菜單的顯示文本
*/
menu.add(Menu.NONE,Menu.FIRST+1,5,"刪除").setIcon(
android.R.drawable.ic_menu_delete);
//setIcon()方法為菜單設置圖標,這里使用的是系統自帶的圖標,同學們留意一下,以
//android.R開頭的資源是系統提供的,我們自己提供的資源是以R開頭的
menu.add(Menu.NONE,Menu.FIRST+2,2,"保存").setIcon(
android.R.drawable.ic_menu_edit);
menu.add(Menu.NONE,Menu.FIRST+3,6,"幫助").setIcon(
android.R.drawable.ic_menu_help);
menu.add(Menu.NONE,Menu.FIRST+4,1,"添加").setIcon(
android.R.drawable.ic_menu_add);
menu.add(Menu.NONE,Menu.FIRST+5,4,"詳細").setIcon(
android.R.drawable.ic_menu_info_details);
menu.add(Menu.NONE,Menu.FIRST+6,3,"發送").setIcon(
android.R.drawable.ic_menu_send);
returntrue;
}
@Override
(MenuItemitem){
switch(item.getItemId()){
caseMenu.FIRST+1:
Toast.makeText(this,"刪除菜單被點擊了",Toast.LENGTH_LONG).show();
break;
caseMenu.FIRST+2:
Toast.makeText(this,"保存菜單被點擊了",Toast.LENGTH_LONG).show();
break;
caseMenu.FIRST+3:
Toast.makeText(this,"幫助菜單被點擊了",Toast.LENGTH_LONG).show();
break;
caseMenu.FIRST+4:
Toast.makeText(this,"添加菜單被點擊了",Toast.LENGTH_LONG).show();
break;
caseMenu.FIRST+5:
Toast.makeText(this,"詳細菜單被點擊了",Toast.LENGTH_LONG).show();
break;
caseMenu.FIRST+6:
Toast.makeText(this,"發送菜單被點擊了",Toast.LENGTH_LONG).show();
break;
}
returnfalse;
}
@Override
publicvoidonOptionsMenuClosed(Menumenu){
Toast.makeText(this,"選項菜單關閉了",Toast.LENGTH_LONG).show();
}
@Override
(Menumenu){
Toast.makeText(this,
"選項菜單顯示之前onPrepareOptionsMenu方法會被調用,你可以用此方法來根據打當時的情況調整菜單",
Toast.LENGTH_LONG).show();
//如果返回false,此方法就把用戶點擊menu的動作給消費了,onCreateOptionsMenu方法將不會被調用
returntrue;
}
}
5.運行效果
3. android怎樣實現菜單欄的按鈕
千鋒扣丁學堂Android開發為您解答:
在 acvitity類中,定義2個類的成員變數
protected static final int Menu_About = Menu.FIRST;
protected static final int Menu_Exit = Menu.FIRST+1;
在類的空白處,右鍵滑鼠按鈕,點[Source]後出現的彈出菜單里點[overried/implments method].
在彈出的對話框里,在Activity里選上onCreateOptionMenu(Menu),點 OK 按鈕.
在程序類代碼會自動覆寫出代碼:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
return super.onCreateOptionsMenu(menu);
}
將 return super.onCreateOptionsMenu(menu); 這句注釋掉.
然後在裡面加入創建菜單項代碼:
super.onCreateOptionsMenu(menu);
menu.add(0,Menu_About,0,"關於").setIcon(R.drawable.icon);
menu.add(0,Menu_Exit,0,"退出").setIcon(R.drawable.icon);
return true;
setIcon(R.drawable.icon); 是設置菜單上的圖片,如果不想要,可以取消.
如何響應菜單被按下的事件呢?需要覆寫onOptionsItemSelected這個方法.
在類的空白處,右鍵滑鼠按鈕,點[Source]後出現的彈出菜單里點[overried/implments method].
在彈出的對話框里,在Activity里選上onOptionsItemSelected(MenuItem ),點 OK 按鈕.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
return super.onOptionsItemSelected(item);
}
把 return super.onOptionsItemSelected(item);注釋掉,寫上
super.onOptionsItemSelected(item);
switch(item.getItemId())
{
case Menu_About:
break;
case Menu_Exit:
break;
}
return true;
如何判斷是哪個按鈕被按了呢?根據item.getItemId()方法獲得某個菜單項的ID,就是我們在類中定義的
protected static final int Menu_About = Menu.FIRST;
protected static final int Menu_Exit = Menu.FIRST+1;
這兩個.
剩下的工作就是想對應某項實現的具體功能了.
正常情況下,菜單不顯示出來的.只有在改activity顯示的時候,按鍵盤上的"MENU"才會顯示出來.
4. mac版 android studio 頂部菜單欄和工具欄怎麼顯示出來
你焦點在android studio的時候 頂部欄就是程序的工具欄 mac所有程序的工具欄都在頂部這個地方
5. 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特性和使用匯總(一)》
6. android UI 怎麼從頂部菜單欄 變成底部菜單欄
實現方式:自定義TabWidget
1、首先創建一個TabWidget的布局文件,main_tab_layout1.xml:
[html] view plain
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0.0dip"
android:layout_weight="1.0" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dip"
android:background="@drawable/tab_widget_background"
android:layout_weight="0.0"/>
</LinearLayout>
</TabHost>
注意:
<1> 不管是使用TabActivity 還是自定義TabHost,都要求以TabHost作為XML布局文件的根;
<2> 將FrameLayout的屬性值layout_weight設置為了1.0,這樣就可以把TabWidget的組件從頂部擠了下來變成了底部菜單欄。
<3> <TabWidger> 和<FrameLayout>的Id 必須使用系統id,分別為android:id/tabs 和 android:id/tabcontent 。因為系統會使用者兩個id來初始化TabHost的兩個實例變數(mTabWidget 和 mTabContent)。
7. android 系統源碼修改 去除下拉菜單,底部菜單
android手機系統的頂部,點擊菜單欄時,會有一個可以下拉的下拉菜單,,,其實就是他的下拉通知欄,,怎麼實現這個下拉的功能
沒分了 見諒
8. 怎麼實現Android頂部菜單按鈕的頁面跳轉
button.setOnClickListener(new OnClickListener(){
Intent intent = new Intent(this,MainAcitivity.class);
startActivity(intent);
});
9. android TabHost 與RadioGroup 結合完成的頂部菜單欄
我怎麼記得addTab加上去的本來就有豎線分割啊,你要實在不行就做一個本身帶豎線的圖片就好了