android ProgressBar和ProgressDialog (inderminate)
来源:互联网 发布:mac怎么导出livephoto 编辑:程序博客网 时间:2024/06/05 02:15
一、ProgressBar 原地展示
XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="start" /> <ProgressBar android:id="@+id/progressBar1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" > </ProgressBar> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="stop" /> </LinearLayout> <ProgressBar android:id="@+id/progressBar2" style="@android:style/Widget.ProgressBar.Small" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" > </ProgressBar> <ProgressBar android:id="@+id/progressBar3" style="@android:style/Widget.ProgressBar.Large" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" > </ProgressBar> <ProgressBar android:id="@+id/progressBar4" style="@android:style/Widget.ProgressBar.Inverse" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" > </ProgressBar> <ProgressBar android:id="@+id/progressBar5" style="@android:style/Widget.ProgressBar.Small.Inverse" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" > </ProgressBar> <ProgressBar android:id="@+id/progressBar6" style="@android:style/Widget.ProgressBar.Large.Inverse" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" > </ProgressBar> <ProgressBar android:id="@+id/progressBar6" style="@android:style/Widget.ProgressBar.Horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" > </ProgressBar> </LinearLayout>
Activity:
public class MainActivity extends Activity {private Button btn = null;private Button btn2 = null;private ProgressBar progressBar = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setupViews(); } private void setupViews() { tv = (TextView)findViewById(R.id.textView1); btn = (Button)findViewById(R.id.button1); btn.setOnClickListener(new OnClickListener(){@Overridepublic void onClick(View arg0) {progressBar.setVisibility(View.VISIBLE); // 显示} }); btn2 = (Button)findViewById(R.id.button2); btn2.setOnClickListener(new OnClickListener(){@Overridepublic void onClick(View arg0) {progressBar.setVisibility(View.GONE); // 隐藏} }); progressBar = (ProgressBar)findViewById(R.id.progressBar1); }}
二、ProgressDialog, 在popup中显示
XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Open ProgressDialog" /> </LinearLayout>
Activity:
public class MainActivity extends Activity {private Button btn = null;private ProgressDialog pd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setupViews(); } private void setupViews() { btn = (Button)findViewById(R.id.button); btn.setOnClickListener(new OnClickListener(){@Overridepublic void onClick(View arg0) {pd = ProgressDialog.show(MainActivity.this, null, "Loading...", true, true);new Thread() {public void run(){try {Thread.sleep(2000); // 业务处理过程} catch (Exception e) {e.printStackTrace();}handler.sendEmptyMessage(0); // 更新UI}}.start();} }); } private Handler handler = new Handler(){ public void handleMessage(Message msg) { pd.dismiss(); }};}
0 0
- android ProgressBar和ProgressDialog (inderminate)
- Android-基本控件(ProgressBar 和 ProgressDialog)
- ProgressBar和ProgressDialog(一)
- ProgressBar和ProgressDialog(二)
- ProgressBar和ProgressDialog(三)
- ProgressBar和ProgressDialog(四)
- Android笔记(6) ---ProgressBar和ProgressDialog的使用
- android关于ProgressBar和ProgressDialog的使用
- progressBar和ProgressDialog使用
- android学习总结(16.08.29)进度条控件ProgressBar和ProgressDialog
- 多样式ProgressBar 和ProgressDialog
- 多样式ProgressBar 和ProgressDialog
- ProgressBar和ProgressDialog的使用
- Android--ProgressBar(进度条)、ProgressDialog(进度条对话框)
- Android自定义progressDialog使用系统ProgressBar与图片实现(一)系统ProgressBar
- ProgressBar&ProgressDialog
- android中ProgressDialog与ProgressBar的使用
- android中ProgressDialog与ProgressBar的使用
- Ruby的GC机制源码分析(4)
- 浏览器问题
- JQuery符号替换
- table隔行变色的css
- 打印java虚拟机的环境变量
- android ProgressBar和ProgressDialog (inderminate)
- navicat linux 破解
- L-BFGS(minFunc):Step direction is illegal
- MyBatis入门示例——MyBatis学习笔记之一
- HTML5/CSS3跨平台开发技术分享(一)
- java 类继承备忘
- jsp基础语法三:
- C/C++ 内存分配方式,堆区,栈区,new/delete/malloc/free
- shell_awk/grep/sort