LoadingView.java
2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.prws.common.view;
import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import com.prws.common.R;
/**
* 加载中的view
*/
public class LoadingView extends ProgressDialog {
private Context mContext;
private View loadingView;
private WindowManager.LayoutParams params;
private String title;
public LoadingView(Context context) {
super(context);
mContext=context;
}
public LoadingView(Context context, int theme) {
super(context, theme);
mContext=context;
}
public LoadingView(Context context, int theme,String str) {
super(context, theme);
mContext=context;
title=str;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
init(mContext);
}
private void init(Context context) {
setCancelable(true);
setCanceledOnTouchOutside(false);
// setContentView(R.layout.layout_null);
// params= getWindow().getAttributes();
// params.width = WindowManager.LayoutParams.WRAP_CONTENT;
// params.height = WindowManager.LayoutParams.WRAP_CONTENT;
// getWindow().setAttributes(params);
// loadingView=View.inflate(context,R.layout.loading,null);
// AnimationDrawable animationDrawable = (AnimationDrawable) loadingView.findViewById(R.id.loading_iv).getBackground();
// if (title != null)
// ((TextView)loadingView.findViewById(R.id.load_dialog_tv)).setText(title);
// //判断是否在运行
// if(!animationDrawable.isRunning()){
// //开启帧动画
// animationDrawable.start();
// }
addContentView(loadingView,params);
}
public LoadingView showDialog() {
super.show();
return this;
}
@Override
public void dismiss() {//关闭
super.dismiss();
}
}