Android編程實(shí)現(xiàn)對話框形式進(jìn)度條功能示例
本文實(shí)例講述了Android編程實(shí)現(xiàn)對話框形式進(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)度天對話框"
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é)》
希望本文所述對大家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)文章
Android自定義圓弧進(jìn)度條加數(shù)字動(dòng)態(tài)變化
這篇文章主要為大家詳細(xì)介紹了Android自定義圓弧進(jìn)度條加數(shù)字動(dòng)態(tài)變化,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-07-07
Android自定義View實(shí)現(xiàn)加載進(jìn)度條效果
這篇文章主要為大家詳細(xì)介紹了Android自定義View實(shí)現(xiàn)加載進(jìn)度條效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05
Android實(shí)現(xiàn)簡單實(shí)用的搜索框
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)簡單實(shí)用的搜索框,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-10-10
Android中懸浮窗口的實(shí)現(xiàn)原理實(shí)例分析
這篇文章主要介紹了Android中懸浮窗口的實(shí)現(xiàn)原理,以實(shí)例形式較為詳細(xì)的分析了Android懸浮窗口的原理與具體實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10

