Android的MaterialDialog微调 [英] Android MaterialDialog Spinner

查看:613
本文介绍了Android的MaterialDialog微调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MaterialDialog.Builder显示一个对话框。
我设置了customView为我的对话框。

I'm using MaterialDialog.Builder to show a dialog. I set a customView for my dialog.

在我的布局我有一个微调,我想填充它构成了我的SQLite数据库,当我显示对话框。

In my layout i have a spinner and i want to populate it form my sqlite database when i show the dialog.

的回调函数,只有当我把这些按钮的工作原理。有没有办法,我可以前对话框将显示使用,使用的布局功能,我设置追加微调?

The callback function only works when i push those buttons. Is there a function that i can use before dialog shows and use the layout that i set to append the spinner ?

我的code是这样的:

My code is like :

boolean wrapInScrollView = true;
new MaterialDialog.Builder(mContext)
.customView(layout, wrapInScrollView)
.autoDismiss(false)
.negativeText(R.string.text40)
.positiveText(buton)
.callback(new MaterialDialog.ButtonCallback() { ....})
.build()
.show();

感谢

推荐答案

假设你有的LinearLayout 键,里面有微调


  • 自定义 XML 文件名为dialogCustom

  • 它里面的
  • 的LinearLayout id是linearLayoutMine

  • 微调内部编号的LinearLayout mySpinner

  • custom xml file name is "dialogCustom"
  • linearlayout id inside it is "linearLayoutMine"
  • spinner id inside linearlayout is "mySpinner"

MaterialDialog.Builder md=new MaterialDialog.Builder(this);

LayoutInflater factory = LayoutInflater.from(this);
final View stdView = factory.inflate(R.layout.dialogCustom, null);
LinearLayout linearLayoutMine (LinearLayout) stdView.findViewById(R.id.linearLayoutMine);
Spinner spinner = (Spinner) linearLayoutMine.findViewById(R.id.mySpinner);

//Load items to spinner

md.title("myTitle")
  .customView(linearLayoutMine, wrapInScrollView)
  .autoDismiss(false)
  .negativeText(R.string.text40)
  .positiveText(buton)
  .callback(new MaterialDialog.ButtonCallback() { ....})
  .build()
  .show();


回调是只为当正,负按钮pressed。

Callbacks are only for when positive, negative buttons are pressed.

这篇关于Android的MaterialDialog微调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆