Android应用程序中加载进度设计
来源:互联网 发布:房屋租赁软件 编辑:程序博客网 时间:2024/06/05 08:33
Android在加载数据(访问数据库或者加载网络数据),需要显示加载进度,其实这个非常简单!
1.加载数据进度显示的XML布局文件
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:background="@drawable/alert" android:layout_gravity="center" android:paddingLeft="10dip" android:paddingRight="10dip" android:paddingTop="20dip" android:paddingBottom="20dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" >
<ProgressBar
android:id="@android:id/progress"
android:layout_marginRight="15dip"
android:layout_gravity="center_vertical|right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:progressDrawable="@drawable/white"
style="?android:attr/progressBarStyleSmall">
</ProgressBar>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@android:id/text1" android:textColor="#fff" android:text="正在加载..."></TextView>
</LinearLayout>
</FrameLayout>
2.加载数据的进度显示类
public class LoadingAlert {
private View mView;
private TextView mText;
public LoadingAlert(Activity activity) {
mView=LayoutInflater.from(activity).inflate(R.layout.loadingalert, null);
mText=(TextView) mView.findViewById(android.R.id.text1);
LinearLayout.LayoutParams lay=new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
lay.gravity=Gravity.CENTER;
activity.addContentView(mView, lay);
}
public LoadingAlert(Dialog dialog) {
mView=dialog.getLayoutInflater().inflate(R.layout.loadingalert, null);
mText=(TextView) mView.findViewById(android.R.id.text1);
ViewGroup.LayoutParams lay=new ViewGroup.LayoutParams(dialog.getWindow().peekDecorView().getWidth(), dialog.getWindow().peekDecorView().getHeight());
dialog.addContentView(mView, lay);
}
public void setMessage(String message){
mText.setText(message);
}
public void hide(){
mView.setVisibility(View.GONE);
}
public void show(){
mView.setVisibility(View.VISIBLE);
}
- Android应用程序中加载进度设计
- android 进度加载条
- Android项目中使用自定义进度加载Dialog
- android中各式各样的进度条,加载进度,太棒了
- android 时钟进度加载器
- Android 自定义加载进度框
- dialog 加载中进度框
- Android加载webView加载进度实现
- Android自定义标题栏:显示网页加载进度
- android webview 实现网页加载进度
- Android自定义view之图片加载进度
- android 网络加载提示进度封装 View
- Android自定义标题栏:显示网页加载进度
- Android WebView加载网页进度监听
- bootloader中显示nk加载进度
- Silverlight中大图片的加载进度
- Android中AsyncTask的处理后台耗时操作(如list排序,进度加载)
- Android 平板上 同时显示多个进度框 正在加载中
- [Linux]Samba server
- [Linux]A Shell to Export Source From SVN
- VC6.0如何生成汇编文件并显示编译选项
- [Linux]Note of 尚学堂
- [Linux]Shut Down Firewall
- Android应用程序中加载进度设计
- Linux平台Makefile文件的编写基础篇
- [Linux]Crond configuration in Ubuntu
- [Linux]Vi Command
- [Linux]Add User Sudo Privileges
- 在ARM中使用Ramdisk
- [Linux]鸟哥的linux私房菜-shell RE
- 关于管理中的一些总结
- [Linux]Apt Commands