欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android普通對(duì)話框用法實(shí)例分析

 更新時(shí)間:2015年09月16日 12:06:53   作者:Ruthless  
這篇文章主要介紹了Android普通對(duì)話框用法,以實(shí)例形式較為詳細(xì)的分析了Android對(duì)話框的創(chuàng)建技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了Android普通對(duì)話框用法。分享給大家供大家參考。具體如下:

main.xml布局文件:

<?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">
 <EditText android:text="" 
  android:id="@+id/editText"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content" 
  android:editable="false"
  android:cursorVisible="false" />
 <Button android:text="顯示普通對(duì)話框" 
  android:id="@+id/button"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content" />
</LinearLayout>

AlertDialog類:

package com.ljq.dialog;
import android.app.Activity;
import android.app.Dialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class AlertDialog extends Activity {
 private EditText editText;
 private final static int DIALOG=1;
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  editText=(EditText)findViewById(R.id.editText);
  Button button = (Button) findViewById(R.id.button);
  button.setOnClickListener(new View.OnClickListener() {
   public void onClick(View v) {
    // 顯示對(duì)話框
    showDialog(DIALOG);
   }
  });
 }
 /**
  * 創(chuàng)建普通對(duì)話框
  */
 @Override
 protected Dialog onCreateDialog(int id) {
  Dialog dialog=null;
  switch (id) {
  case DIALOG:
   Builder builder=new android.app.AlertDialog.Builder(this);
   //設(shè)置對(duì)話框的圖標(biāo)
   builder.setIcon(R.drawable.header);
   //設(shè)置對(duì)話框的標(biāo)題
   builder.setTitle("普通對(duì)話框");
   //設(shè)置對(duì)話框的顯示內(nèi)容
   builder.setMessage("這是普通對(duì)話框中的內(nèi)容??!");
   //添加按鈕,android.content.DialogInterface.OnClickListener.OnClickListener
   builder.setPositiveButton(" 確 定 ", new OnClickListener(){
    public void onClick(DialogInterface dialog, int which) {
     editText.setText("這是普通對(duì)話框中的內(nèi)容?。?);
    }
   });
   //創(chuàng)建一個(gè)普通對(duì)話框
   dialog=builder.create();
   break;
  }
  return dialog;
 }
}

運(yùn)行結(jié)果:

希望本文所述對(duì)大家的Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • android效果TapBarMenu繪制底部導(dǎo)航欄的使用方式示例

    android效果TapBarMenu繪制底部導(dǎo)航欄的使用方式示例

    本篇文章主要介紹了android效果TapBarMenu繪制底部導(dǎo)航欄的使用方式,具有一定的參考價(jià)值,有興趣的可以了解一下。
    2017-01-01
  • Android 用HttpURLConnection訪問(wèn)網(wǎng)絡(luò)的方法

    Android 用HttpURLConnection訪問(wèn)網(wǎng)絡(luò)的方法

    下面小編就為大家分享一篇Android 用HttpURLConnection訪問(wèn)網(wǎng)絡(luò)的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-01-01
  • android上實(shí)現(xiàn)0.5px線條的原理分析

    android上實(shí)現(xiàn)0.5px線條的原理分析

    這篇文章主要介紹了android上實(shí)現(xiàn)0.5px線條的原理分析,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-01-01
  • Android開(kāi)發(fā)技巧之像QQ一樣輸入文字和表情圖像

    Android開(kāi)發(fā)技巧之像QQ一樣輸入文字和表情圖像

    QQ聊天輸入框,在輸入框中可以同時(shí)輸入文字和表情圖像。實(shí)際上,這種效果在Android SDK中只需要幾行代碼就可以實(shí)現(xiàn),本文將會(huì)介紹如何實(shí)現(xiàn)像QQ一樣輸入表情圖像
    2013-01-01
  • Kotlin比較與解釋Lazy與Lateinit的用法

    Kotlin比較與解釋Lazy與Lateinit的用法

    在使用kotlin開(kāi)發(fā)中,因?yàn)楦鞣N原因,我們會(huì)經(jīng)常需要使用到延遲加載的功能,目前kotlin的延遲加載主要有兩種:lateinit和lazy,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值
    2023-02-02
  • Android?音頻波形圖實(shí)現(xiàn)效果示例

    Android?音頻波形圖實(shí)現(xiàn)效果示例

    這篇文章主要為大家介紹了Android?音頻波形圖實(shí)現(xiàn)效果示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-08-08
  • Android 實(shí)用工具之emulator介紹

    Android 實(shí)用工具之emulator介紹

    Android 實(shí)用工具之emulator介紹,需要的朋友可以參考一下
    2013-02-02
  • Android通過(guò)LIstView顯示文件列表的兩種方法介紹

    Android通過(guò)LIstView顯示文件列表的兩種方法介紹

    過(guò)ListView顯示SD卡中的文件列表一共有兩種方法,一是:通過(guò)繼承ListActivity顯示;二是:利用BaseAdapter顯示,具體實(shí)現(xiàn)如下,感興趣的朋友可以參考下哈
    2013-06-06
  • android shape的使用及漸變色、分割線、邊框、半透明陰影

    android shape的使用及漸變色、分割線、邊框、半透明陰影

    這篇文章主要介紹了android shape的使用及漸變色、分割線、邊框、半透明陰影,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-08-08
  • android分享純圖片到QQ空間實(shí)現(xiàn)方式

    android分享純圖片到QQ空間實(shí)現(xiàn)方式

    今天小編就為大家分享一篇關(guān)于android分享純圖片到QQ空間實(shí)現(xiàn)方式,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2019-04-04

最新評(píng)論