【问题标题】:How to get the checked radio button on a custom dialog?如何在自定义对话框上获取选中的单选按钮?
【发布时间】:2013-01-29 22:51:33
【问题描述】:

我怎么可能得到在自定义对话框中选中的单选按钮。 我有一个自定义对话框,其中包含 2 个单选按钮,但每次单击单选按钮时,都会发生空指针异常。

【问题讨论】:

  • 嗨。如果您发布代码,将会很有帮助。 :)

标签: android dialog radio-button


【解决方案1】:

在初始化单选按钮时使用RadioButton rb = (RadioButton)dialog.findViewById(R.id.radiobutton); 而不是RadioButton rb = (RadioButton)findViewById(R.id.radiobutton);

【讨论】:

  • @user2049309:有帮助吗?
  • 在你发帖之前我已经知道答案了 :) 我也是这样做的。谢谢:)
  • 这不代表你知道答案,他贴出正确的答案,你必须给他正确的答案标签。
猜你喜欢
  • 2019-06-18
  • 2011-07-19
  • 2012-01-07
  • 1970-01-01
  • 2014-02-28
  • 2011-07-28
  • 2015-12-13
  • 2015-12-07
  • 2014-10-20
相关资源
最近更新 更多