Android編程實(shí)現(xiàn)對(duì)話框形式進(jìn)度條功能示例
本文實(shí)例講述了Android編程實(shí)現(xiàn)對(duì)話框形式進(jìn)度條功能。分享給大家供大家參考,具體如下:
MainActivity代碼如下:
package com.example.myapplication; import android.app.ProgressDialog; import android.content.DialogInterface; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; public class MainActivity extends AppCompatActivity implements View.OnClickListener { ProgressDialog prodialog; Button show; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); show = (Button) findViewById(R.id.show); show.setOnClickListener(this); } @Override public void onClick(View view) { prodialog = new ProgressDialog(MainActivity.this); prodialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); prodialog.setTitle("腳本之家"); prodialog.setMessage("jb51"); prodialog.setIcon(R.mipmap.ic_launcher); //設(shè)計(jì)進(jìn)度條屬性 prodialog.setMax(100); prodialog.incrementProgressBy(50); //明確顯示進(jìn)度 prodialog.setIndeterminate(false); prodialog.setButton(DialogInterface.BUTTON_POSITIVE,"確定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Toast.makeText(MainActivity.this,"hello",Toast.LENGTH_LONG).show(); } }); prodialog.setCancelable(true); prodialog.show(); } }
布局文件:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="com.example.myapplication.MainActivity"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="顯示進(jìn)度天對(duì)話框" android:id="@+id/show" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> </RelativeLayout>
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android開發(fā)入門與進(jìn)階教程》、《Android調(diào)試技巧與常見問題解決方法匯總》、《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
- Android自定義雙向進(jìn)度條的實(shí)現(xiàn)代碼
- Android編程自定義進(jìn)度條顏色的方法詳解
- Android 自定義view實(shí)現(xiàn)進(jìn)度條加載效果實(shí)例代碼
- Android自定義View仿華為圓形加載進(jìn)度條
- Android進(jìn)度條控件progressbar使用方法詳解
- Android實(shí)現(xiàn)文件解壓帶進(jìn)度條功能
- Android實(shí)現(xiàn)蝸牛進(jìn)度條效果
- android 中win10 使用uwp控件實(shí)現(xiàn)進(jìn)度條Marquez效果
- Android自定義圓形進(jìn)度條
- Android自定義View實(shí)現(xiàn)環(huán)形進(jìn)度條的思路與實(shí)例
- android自定義進(jìn)度條漸變色View的實(shí)例代碼
相關(guān)文章
Flutter實(shí)現(xiàn)彈窗攔截器的示例代碼
彈窗的排隊(duì)執(zhí)行在App中是一個(gè)很常見的應(yīng)用場(chǎng)景,這篇文章為大家介紹了兩個(gè)Flutter實(shí)現(xiàn)彈窗攔截器的示例代碼,感興趣的小伙伴可以學(xué)習(xí)一下2023-09-09Android直播軟件搭建之實(shí)現(xiàn)背景顏色滑動(dòng)漸變效果的詳細(xì)代碼
這篇文章主要介紹了Android直播軟件搭建之實(shí)現(xiàn)背景顏色滑動(dòng)漸變效果的詳細(xì)代碼,代碼簡(jiǎn)單易懂,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-09-09Android App開發(fā)中將View或Drawable轉(zhuǎn)為Bitmap的方法
這篇文章主要介紹了Android App開發(fā)中將View或Drawable轉(zhuǎn)為Bitmap的方法,其中View轉(zhuǎn)換時(shí)作者特別提到了getDrawingCache=null問題的解決方法,需要的朋友可以參考下2016-03-03Android模仿知乎的回答詳情頁(yè)的動(dòng)畫效果
這篇文章主要介紹了Android模仿“知乎”的回答詳情頁(yè)的動(dòng)畫效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-02-02Android多點(diǎn)觸控實(shí)現(xiàn)對(duì)圖片放大縮小平移,慣性滑動(dòng)等功能
這篇文章主要介紹了Android多點(diǎn)觸控實(shí)現(xiàn)對(duì)圖片放大縮小平移,慣性滑動(dòng)等功能的相關(guān)資料,需要的朋友可以參考下2016-02-02flutter InheritedWidget使用方法總結(jié)
這篇文章主要為大家介紹了flutter InheritedWidget使用方法總結(jié)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11解決Android ListView數(shù)據(jù)為空及加載錯(cuò)誤的方法
這篇文章主要為大家提供了一個(gè)解決Android ListView數(shù)據(jù)為空及加載錯(cuò)誤的方法,感興趣的小伙伴們可以參考一下2016-02-02ionic App 解決android端在真機(jī)上tab處于頂部的問題
這篇文章主要介紹了ionic App 解決android端在真機(jī)上tab處于頂部的問題的相關(guān)資料,需要的朋友可以參考下2017-06-06Android編程實(shí)現(xiàn)TextView字體顏色設(shè)置的方法小結(jié)
這篇文章主要介紹了Android編程實(shí)現(xiàn)TextView字體顏色設(shè)置的方法,結(jié)合實(shí)例形式總結(jié)分析了Android針對(duì)TextView字體顏色設(shè)置的相關(guān)步驟與注意事項(xiàng),具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-12-12