android – AlertDialog setTitle()和FragmentDialog中的setMessage等价物

android – AlertDialog setTitle()和FragmentDialog中的setMessage等价物,第1张

概述我正在重写Honeycomb的现有应用程序,但我遇到了一个问题.在现有应用程序中,我们使用默认标题和消息值创建AlertDialog,然后在需要时替换它们.要替换它们,我们使用setTitle()和setMessage(): AlertDialog dialog = getDialog();if (some condition) { dialog.setTitle(R.string.er 我正在重写Honeycomb的现有应用程序,但我遇到了一个问题.在现有应用程序中,我们使用默认标题和消息值创建AlertDialog,然后在需要时替换它们.要替换它们,我们使用setTitle()和setMessage():

AlertDialog dialog = getDialog();if (some condition) {    dialog.setTitle(R.string.error1);    dialog.setMessage(getResources().getString(R.string.error1_msg));}else {    dialog.setTitle(R.string.error2);    dialog.setMessage(getResources().getString(R.string.error2_msg));}

但是,现在我们正在使用DialogFragment,没有setTitle()或setMessage()的方法,因此我们无法在创建后更改它.这种情况有解决方法,还是我们运气不好?

解决方法 您必须扩展DialogFragment以提供内容.有关示例和其他选项,请参见 documentation. 总结

以上是内存溢出为你收集整理的android – AlertDialog setTitle()和FragmentDialog中的setMessage等价物全部内容,希望文章能够帮你解决android – AlertDialog setTitle()和FragmentDialog中的setMessage等价物所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1124250.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存