首页 >> 生活 >

progressdialog什么意思(progressdialog)

2022-07-24 17:40:03 来源: 用户: 

大家好,小经来为大家解答以上问题。progressdialog什么意思,progressdialog很多人还不知道,现在让我们一起来看看吧!

1、 在生命文件夹下创建sf_progress_dialog_anim.xml,实现转动的效果:

2、 ?可扩展标记语言版本='1.0'编码='utf-8'?

3、 动画列表xmlns:Android='http://模式。安卓。'com/apk/RES/Android'

4、 android:oneshot='false'

5、 项目

6、 Android:drawable='@drawable/SF_progress_1'

7、 android:duration='200'/

8、 项目

9、 Android:drawable='@drawable/SF_progress_2'

10、 android:duration='200'/

11、 项目

12、 Android:drawable='@drawable/SF_progress_3'

13、 android:duration='200'/

14、 项目

15、 Android:drawable='@drawable/SF_progress_4'

16、 android:duration='200'/

17、 项目

18、 Android:drawable='@drawable/SF_progress_5'

19、 android:duration='200'/

20、 项目

21、 Android:drawable='@drawable/SF_progress_6'

22、 android:duration='200'/

23、 项目

24、 Android:drawable='@drawable/SF_progress_7'

25、 android:duration='200'/

26、 项目

27、 Android:drawable='@drawable/SF_progress_8'

28、 android:duration='60'/

29、 /动画列表

30、 其中:android:oneshot表示动画只播放一次停留在最后一帧上,当设置为错误的时,则代表动画循环播放;否则,则代表动画只播放一次。

31、 资源文件可到如下链接进行下载:

32、 http://download.csdn.net/detail/shenjichao2008/8248073

33、 在价值观念文件夹中创建style.xml,自定义进度对话框的样式:

34、 stylename='SF_dialogcustom'parent='@Android:style/Theme.'对话框'

35、 itemname='Android:窗口框架'@null/item

36、 itemname='Android:windowsisfloating'true/item

37、 itemname='Android:windowcontentoverlay'@null/item

38、 itemname='Android:windowanimationstyle'@Android:style/Animation.对话框/项目

39、 itemname='Android:windowsoftinputmode'状态未指定|调整平移/项目

40、 /风格

41、 stylename='SF_pressdialogcustom'parent='@style/SF_dialogcustom'

42、 项目名称

43、<itemname="android:windowNoTitle">true</item>

44、</style>

45、在layout文件夹中创建sf_view_custom_progress_dialog.xml,自定义progressdilaog的布局:

46、<?xmlversion="1.0"encoding="utf-8"?>

47、<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

48、android:layout_width="match_parent"

49、android:layout_height="match_parent"

50、android:orientation="horizontal">

51、<ImageView

52、android:id="@+id/sf_iv_progress_dialog_loading"

53、android:layout_width="wrap_content"

54、android:layout_height="wrap_content"

55、android:background="@anim/sf_progress_dialog_anim"

56、android:contentDescription="@string/sf_progress_dialog_image_loading"/>

57、<TextView

58、android:id="@+id/sf_tv_progress_dialog_loading"

59、style="@style/SF_MediumLightGreyTxt"

60、android:layout_width="wrap_content"

61、android:layout_height="wrap_content"

62、android:layout_gravity="center_vertical"/>

63、</LinearLayout>

64、创建SFProgrssDialog类,继承Dialog,实现如下:

65、packagecom.snapfish.view;

66、importcom.snapfish.R;

67、importandroid.app.Dialog;

68、importandroid.content.Context;

69、importandroid.graphics.drawable.AnimationDrawable;

70、importandroid.text.TextUtils;

71、importandroid.view.Gravity;

72、importandroid.widget.ImageView;

73、importandroid.widget.TextView;

74、publicclassSFProgrssDialogextendsDialog{

75、 privatestaticSFProgrssDialogm_progrssDialog;

76、 privateSFProgrssDialog(Contextcontext,inttheme){

77、 super(context,theme);

78、 }

79、 publicstaticSFProgrssDialogcreateProgrssDialog(Contextcontext){

80、 m_progrssDialog=newSFProgrssDialog(context,

81、 R.style.SF_pressDialogCustom);

82、 m_progrssDialog.setContentView(R.layout.sf_view_custom_progress_dialog);

83、 m_progrssDialog.getWindow().getAttributes().gravity=Gravity.CENTER;

84、 returnm_progrssDialog;

85、 }

86、 @Override

87、 publicvoidonWindowFocusChanged(booleanhasFocus){

88、 if(null==m_progrssDialog)

89、 return;

90、 ImageViewloadingImageView=(ImageView)m_progrssDialog

91、 .findViewById(R.id.sf_iv_progress_dialog_loading);

92、 AnimationDrawableanimationDrawable=(AnimationDrawable)loadingImageView

93、 .getBackground();

94、 animationDrawable.start();

95、 }

96、 publicSFProgrssDialogsetMessage(Stringmsg){

97、 TextViewloadingTextView=(TextView)m_progrssDialog

98、 .findViewById(R.id.sf_tv_progress_dialog_loading);

99、 if(!TextUtils.isEmpty(msg))

100、 loadingTextView.setText(msg);

101、 else

102、 loadingTextView.setText(R.string.sf_progress_dialog_image_loading);

103、 returnm_progrssDialog;

104、 }

105、}

106、编写显示/隐藏progressdialog的方法:

107、privateSFProgrssDialogm_customProgrssDialog;

108、finalvoidshowCustomProgrssDialog(Stringmsg){

109、 if(null==m_customProgrssDialog)

110、 m_customProgrssDialog=SFProgrssDialog

111、 .createProgrssDialog(m_parent);

112、 if(null!=m_customProgrssDialog){

113、 m_customProgrssDialog.setMessage(msg);

114、 m_customProgrssDialog.show();

115、 m_customProgrssDialog.setCancelable(false);

116、 }

117、 }

118、finalvoidhideCustomProgressDialog(){

119、 if(null!=m_customProgrssDialog){

120、 m_customProgrssDialog.dismiss();

121、 m_customProgrssDialog=null;

122、 }

123、 }

124、在网络请求之前,调用showCustomProgrssDialog方法,传入显示的message;在网络响应之后,调用hideProgressDialog方法,消除progressdialog。

本文到此结束,希望对大家有所帮助。

  免责声明:本文由用户上传,与本网站立场无关。财经信息仅供读者参考,并不构成投资建议。投资者据此操作,风险自担。 如有侵权请联系删除!

 
分享:
最新文章