public class FlippingLoadingDialog extends BaseDialog {界面布局:
private FlippingImageView mFivIcon;
private TextView mHtvText;
private String mText;
public FlippingLoadingDialog(Context context, String text) {
super(context);
mText = text;
init();
}
private void init() {
setContentView(R.layout.common_flipping_loading_diloag);
mFivIcon = (FlippingImageView) findViewById(R.id.loadingdialog_fiv_icon);
mHtvText = (TextView) findViewById(R.id.loadingdialog_htv_text);
mFivIcon.startAnimation();
mHtvText.setText(mText);
}
public void setText(String text) {
mText = text;
mHtvText.setText(mText);
}
@Override
public void dismiss() {
if (isShowing()) {
super.dismiss();
}
}
}
<?xml version="1.0" encoding="utf-8"?>为了演示运行效果,在TextView中设置一个文字看看显示效果:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:background="@drawable/bg_common_toast" >
<com.example.wechat.widget.FlippingImageView
android:id="@+id/loadingdialog_fiv_icon"
android:layout_width="30dip"
android:layout_height="30dip"
android:src="@drawable/ic_logo_blue" />
<TextView
android:id="@+id/loadingdialog_htv_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_gravity="center_vertical"
android:gravity="left|center"
android:textColor="@color/black"
android:textSize="14sp" />
</LinearLayout>
使用方法:
getLoadingDialog("正在登录...").dismiss();
涉及到的类:
BaseDialog
com.example.wechat.widget.FlippingImageView
后面逐一讲解。