[英]How to display new android progress dialog in flutter plugin?
I am building flutter plugin and try to show native progress dialog with the code below.我正在构建颤振插件并尝试使用下面的代码显示本机进度对话框。
ProgressDialog progressDialog =new ProgressDialog(context);
progressDialog.setTitle("Downloading");
progressDialog.setMessage("Please wait while downloading map");
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.show();
And the dialog is displaying as below.对话框显示如下。
What I am expecting is default new android dialog when we create native android project like below.当我们创建如下所示的原生 android 项目时,我期待的是默认的新 android 对话框。
What are the changes I need to do to make it work?我需要做哪些更改才能使其正常工作?
[Update] This is the default AndroidManifest.xml code [更新] 这是默认的 AndroidManifest.xml 代码
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.map_plugin">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
</manifest>
I have added application tag and added several style to this but none work我添加了应用程序标签并为此添加了几种样式,但没有任何效果
<application android:theme="@android:style/Theme.Material.Light.DarkActionBar"></application>
In your styles.xml file在您的 styles.xml 文件中
<style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/colorPrimary</item>
</style>
And to use it:并使用它:
ProgressDialog progressDialog = new ProgressDialog(context, R.style.MyAlertDialogStyle);
progressDialog.setTitle("Downloading");
progressDialog.setMessage("Please wait while downloading map");
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.show();
Hope this will help you to achieve this希望这将帮助您实现这一目标
Change theme in AndroidManifest.xml.在 AndroidManifest.xml 中更改主题。 See Styles and Themes for details.有关详细信息,请参阅样式和主题。
<manifest ... />
<application android:theme="<your theme>"
...>
...
</application>
</manifest>
Or try to pass the theme in ProgressDialog(Context context, int theme)
constructor.或者尝试在ProgressDialog(Context context, int theme)
构造函数中传递主题。
you can use this library:你可以使用这个库:
https://pub.dev/packages/sn_progress_dialog https://pub.dev/packages/sn_progress_dialog
or或者
showLoaderDialog(BuildContext context){
AlertDialog alert=AlertDialog(
content: new Row(
children: [
CircularProgressIndicator(),
Container(margin: EdgeInsets.only(left:7),child:Text("Loading..." )),
],),
);
showDialog(barrierDismissible: false,
context:context,
builder:(BuildContext context){
return alert;
},
);
}
don't forget to dismiss when your data is fetched.获取数据时不要忘记关闭。
Navigator.pop(context);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.