Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我怎么可能得到在自定义对话框中选中的单选按钮。我有一个自定义对话框,其中包含 2 个单选按钮,但每次单击单选按钮时,都会发生空指针异常。
在初始化单选按钮时使用RadioButton rb = (RadioButton)dialog.findViewById(R.id.radiobutton);而不是RadioButton rb = (RadioButton)findViewById(R.id.radiobutton);
RadioButton rb = (RadioButton)dialog.findViewById(R.id.radiobutton);
RadioButton rb = (RadioButton)findViewById(R.id.radiobutton);