对话框中的拖动条
package com.ko8e;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MyActivity extends Activity {
/** Called when the activity is first created. */
private Button button1 = null;
private Button button2 = null;
private ProgressDialog pDialog = null;
int count = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button1.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
pDialog = new ProgressDialog(MyActivity.this);
pDialog.setIcon(R.drawable.img1);
pDialog.setTitle("提示");
pDialog.setMessage("这是一个圆形的进度条");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pDialog.setButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
MyActivity.this.finish();
}
});
pDialog.show();
}
});
button2.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
count = 0;
pDialog = new ProgressDialog(MyActivity.this);
pDialog.setIcon(R.drawable.img2);
pDialog.setTitle("提示");
pDialog.setMessage("这是一个长形进度条");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pDialog.setMax(100);
pDialog.show();
new Thread(new Runnable() {
public void run() {
try {
while (count <= 100) {
Thread.sleep(100);
pDialog.setProgress(count++);
}
pDialog.cancel();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
}
});
}
}
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"
>
<TextView
android:id="@+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button1"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button2"
/>
</LinearLayout>
分享到:
相关推荐
Android自定义类似ProgressDialog效果的Dialog
2个按钮,左边为ProgressBar事件,点击后隐藏/显示 ProgressBar ;右边为ProgressDialog事件,实现点击后弹出ProgressDialog,并在3s(耗时操作)后消失
执行耗时操作时,为了安抚用户等待的烦躁心情我们一般会使用进度条之类的空间,在android中让大家最容易想到的就是progressbar或者progressDialog. 源码的详细说明链接:...
android常见控件的使用方法androidTextView,Button,EditText,ImageView,ProgressBar,AlertDialog,ProgressDialog
这是一个集成目前Android主流优秀第三方组件、优秀好用的自定义控件、实用工具类封装、以及一些APP共通模块(比如:版本更新、意见反馈、引导界面等等)的开发包,帮助程序员快速开发自己的APP 已集成第三方开源...
4.2.22 对话框中的进度条(ProgressDialog) 4.3 界面布局 4.3.1 垂直线性布局 4.3.2 水平线性布局 4.3.3.相对布局(RelativeLayout) 4.3.4 表单布局(TableLayout) 4.3.5 切换卡(TabWidget) 4,4 小结 第5章 Android...
TextView,Button,EditText,ImageView,ProgressBar,AlterDialog,ProgressDialog的综合使用。 适合新手。 包括:edittext登陆页面的设置,加载对话框的基本使用方法,警告对话框的基本使用, 进度条与Timer...
ProgressBar是Android中很常用的一个控件,也就是进度条,但是系统的进度条实在是...这里是一个简单的CustomProgressDialogDemo
学习android的好例子-登录注册 ...控件使用:Button,TextView,EditText,CheckBox 布局:LinearLayout 类:Handler,Toast,ProgressDialog 远程登录,与服务器交互 基本事件的使用等等 很全面,很实用的一个例子哦!
4.2.22 对话框中的进度条(ProgressDialog) 4.3 界面布局 4.3.1 垂直线性布局 4.3.2 水平线性布局 4.3.3.相对布局(RelativeLayout) 4.3.4 表单布局(TableLayout) 4.3.5 切换卡(TabWidget) 4,4 小结 第5章 Android...
AlertDialog和ProgressDialog界面对话框的使用(主),基础控件(TextView、Button、EditText、ImageView)的使用(副),附带一个按键进度条。
Android四大布局及三个控件,介绍了安卓的四大布局使用方法,以及AlertDialog,ProgressBar,ProgressDialog的使用。
这是一个集成目前Android主流优秀第三方组件、优秀好用的自定义控件、实用工具类封装、以及一些APP共通模块(比如:版本更新、意见反馈、引导界面等等)的开发包,帮助程序员快速开发自己的APP 已集成第三方开源...
Android中的控件的使用方式和iOS中控件的使用方式基本相同,都是事件驱动。给控件添加事件也有接口回调和委托代理的方式。今天这篇博客就总结一下Android中常用的基本控件以及布局方式。说到布局方式Android和iOS...
ProgressDialog是继承自Android.app.ProgressDialog所设计的互动对话窗口,应用时,必须新建ProgressDialog对象,运行时会弹出“对话框”作为提醒,此时应用程序后台失去焦点,直到进程结束后,才会将控制权交给应用...
在Android中ProgressDialog是非常常用的控件,但是系统提供的控件,确实有点难看,所以我们需要自定义,这个例子是我在别人自定义的基础上修改的,希望和大家多多交流
ImageView 进度条:ProgressBar、ProgressDialog、SeekBar、RatingBar 选择器:DatePicker、TimePicker 菜单:Menu、ContentMenu 对话框:Dialog、ProgressDialog 常用的控件有文本框、按钮和列表等。 2.控件的实现 ...
ScreenShot Git@OSC非官方android客户端 ...ProgressBar,ProgressDialog等控件在android L平台下不会随着主题变化而变化 引用到的开源库: compile 'com.android.support:design:22.2.0' compile 'com.jakewharton:butt
自定义progressDialog,android实用工具类
3.18 程序加载中,请稍后——ProgressDialog与线程整合应用 3.19 全屏幕以按钮覆盖——动态产生按钮并最大化 3.20 今晚到哪儿打牙祭——具有选择功能的对话框 3.21 Android变脸——主题(Theme)...