導航:首頁 > 操作系統 > android菜單項

android菜單項

發布時間:2023-08-25 16:29:57

android系統菜單怎麼調出

最簡單的辦法是按菜單鍵,如果連菜單鍵是那個都不知道,建議去有關專業網站學飛,因為要從ABD講起,恐怕這里講不下來。再簡單的辦法就是和按某一項,就會跳出菜單,比如長按一個圖標會跳出關對於對這個圖標下一步操作的菜單選項,長按要輸入文本的地方會跳出輸入法選擇,長按一張圖片會文本文件會跳出刪除、復制等文件操作菜單。

網路 機鋒網 ,注冊登錄,進入你手機型號專用論壇學習學習吧。

❷ android 點擊按鈕時顯示菜單應怎樣實現

點擊button彈出對話框菜單

importandroid.app.Activity;

importandroid.app.AlertDialog;

importandroid.content.DialogInterface;

importandroid.os.Bundle;

importandroid.view.View;

importandroid.view.View.OnClickListener;

importandroid.widget.Button;

{

privateButtonbutton;

/**.*/

@Override

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

button=(Button)findViewById(R.id.button1);

button.setOnClickListener(newOnClickListener(){

@Override

publicvoidonClick(Viewarg0){

newAlertDialog.Builder(choice.this)

.setTitle("choice")

.setItems(R.array.str_body,newDialogInterface.OnClickListener(){

@Override

publicvoidonClick(DialogInterfacearg0,intarg1){

//TODOAuto-generatedmethodstub

String[]aryshop=getResources().getStringArray(R.array.str_body);

newAlertDialog.Builder(choice.this)

.setMessage(aryshop[arg1])

.setNegativeButton("ok",newDialogInterface.OnClickListener(){

@Override

publicvoidonClick(DialogInterfacearg0,intarg1){

//TODOAuto-generatedmethodstub

}

}).show();

}

}).show();

//TODOAuto-generatedmethodstub

}});

}

}

菜單項

<?xmlversion="1.0"encoding="utf-8"?>

<resources>

<stringname="hello">HelloWorld,choice!</string>

<stringname="app_name">ChoiceMenu</string>

<stringname="strtitle">按我選擇:</string>

<stringname="str">你選擇的是:</string>

<arrayname="str_body">

<item>選項1</item>

<item>選項2</item>

<item>選項3</item>

<item>選項4</item>

<item>選項5</item>

<item>選項6</item>

</array>

</resources>

❸ 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菜單項相關的資料

熱點內容
安卓手機刷新不了ins怎麼辦 瀏覽:435
python判斷ip網段 瀏覽:362
穿越火線更新怎麼開新伺服器 瀏覽:315
腹部超聲pdf 瀏覽:920
解壓縮全能王能解壓7z文件嗎 瀏覽:248
python目錄比較 瀏覽:645
公司程序員戴假發 瀏覽:345
oracle查看資料庫狀態命令 瀏覽:840
查汽車app叫什麼 瀏覽:747
經濟學英文pdf下載 瀏覽:798
python列表順序 瀏覽:698
雲南邊緣計算伺服器雲伺服器 瀏覽:105
小公司如何選擇伺服器 瀏覽:791
android指紋識別驅動 瀏覽:447
榮耀手機的系統有方舟編譯器嗎 瀏覽:629
單片機應用的論文 瀏覽:474
什麼app可以查網購的真偽 瀏覽:444
培訓班的程序員怎麼樣找工作 瀏覽:813
codeblocks編譯器位數 瀏覽:447
bios加密怎麼設置 瀏覽:350