欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

如何在Android中自定義Dialog

本篇文章為大家展示了如何在Android中自定義Dialog,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

廣靈網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,廣靈網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為廣靈上千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請找那個售后服務(wù)好的廣靈做網(wǎng)站的公司定做!

功能:

android 提供給我們的只有2種Dialog 即 AlertDialog & ProgressDialog 但是 Dialog 有其自身的特點:1. 不是 Activity 2. 開銷比 Activity 小得多

原理:

1. android 系統(tǒng)提供了一個class: Dialog. 而且你可以把自己的工作放在"protected void onCreate(Bundle savedInstanceState)" 在里面先調(diào)用系統(tǒng)的"super.onCreate(savedInstanceState)" 其就會保證調(diào)用這個method.

2. 至于 Dialog 界面的定制 可以寫一個xml 文件 然后 在 "void onCreate(Bundle)" 通過 "setContentView()" 來使之生效

3. Dialog 使用問題: 1. 彈出:show() 2. 取消:dismiss()

代碼:

1. 創(chuàng)建一個 Dialog:

public class CustomDialog extends Dialog {
  public CustomDialog(Context context) {
    super(context);
    // TODO Auto-generated constructor stub
  }
  protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.custom_dialog);
    setTitle("Custom Dialog");
    TextView text = (TextView)findViewById(R.id.text);
    text.setText("Hello, this is a custom dialog!");
    ImageView image = (ImageView)findViewById(R.id.image);
    image.setImageResource(R.drawable.sepurple);
    Button buttonYes = (Button) findViewById(R.id.button_yes);
    buttonYes.setHeight(5);
    buttonYes.setOnClickListener(new Button.OnClickListener(){
      public void onClick(View v) {
        // TODO Auto-generated method stub
        dismiss();
      }
    });
    Button buttonNo = (Button) findViewById(R.id.button_no);
    buttonNo.setSingleLine(true);
    buttonNo.setOnClickListener(new Button.OnClickListener(){
      public void onClick(View v) {
        // TODO Auto-generated method stub
        dismiss();
      }
    });
  }
  //called when this dialog is dismissed
  protected void onStop() {
    Log.d("TAG","+++++++++++++++++++++++++++");
  }
}

2. Dialog 的使用:

public class CustomDialogUsage extends Activity {
  CustomDialog cd;
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    cd = new CustomDialog(this);
    Button buttonYes = (Button) findViewById(R.id.main_button);
    buttonYes.setOnClickListener(new OnClickListener(){
      public void onClick(View v) {
        // TODO Auto-generated method stub
        cd.show();
      }
    });
  }
}

3. Dialog 的界面定制:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root" android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:padding="10dp">
  <ImageView android:id="@+id/image" android:layout_width="wrap_content"
  android:layout_height="fill_parent" android:layout_marginRight="10dp"
  />
  <LinearLayout android:orientation="vertical"
  android:layout_width="fill_parent" android:layout_height="wrap_content"
  android:padding="5px">
    <TextView android:id="@+id/text" android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:textColor="#FFF" />
    <LinearLayout android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="5px">
      <Button android:id="@+id/button_yes"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text=" Yes " android:gravity="center"
      />
      <Button android:id="@+id/button_no"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text=" No " android:gravity="center"
      />
    </LinearLayout>
  </LinearLayout>
</LinearLayout>

上述內(nèi)容就是如何在Android中自定義Dialog,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

網(wǎng)頁題目:如何在Android中自定義Dialog
鏈接URL:http://aaarwkj.com/article2/ggoooc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、域名注冊、網(wǎng)站排名服務(wù)器托管、、Google

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)
久热视频这里只有精品99| av在线男人社区日韩| 亚洲欧美日韩在线第三页| 射精视频在线观看免费| 最近av中文字幕电影| 日韩精品亚洲一级在线观看| av一区二区三区不卡在线看| 欧美精品久久在线观看| 丁香婷婷激情五月天综合| 国产一区二区精品久久岳| 精品久久久噜噜噜久久| 丝袜亚洲激情欧美日韩偷拍| 亚洲黄色录像一区二区人妻黑人| 日本午夜福利免费在线播放| 日本一区二区高清在线观看| 午夜在线精品福利视频| 青青草成人免费在线公开视频| 国产欧美日韩亚洲精品区| 日韩视频精品一区二区| 中文字幕日韩精品久久| 99精品一二三日韩| 亚洲欧美成人免费视频| 一本之道高清久久久首页| 国产亚洲日本一区二区三区| 粗长挺进新婚人妻诗岚| 日本一区二区中文字幕在线 | 亚洲香蕉视频在线播放| 国产极品av一区二区三区| 欧美日韩一区二区激情在线| 日本久久久视频在线观看| 亚洲欧洲一区二区免费| 丝袜美腿一区二区三区| 日本日韩一区二区国产| 韩国av网址在线观看| 国产中文字二暮区2021综合| 国产在线精品专区第一页| 美女午夜精品国产福利| 国产传媒视频在线免费观看| 日本一区二区不卡视频在线播放| 国产一区二区毛多内射| 日韩欧美国产午夜精品|