findViewById的问题
aide吧
全部回复
仅看楼主
level 12
星空雨灵 楼主
症状:闪退,放在activity里,在打开该activity的时候闪退。放在对话框里,启动对话框时闪退。而且任何控件都是这样。
Spinner spinner = (Spinner) findViewById(R.id.spinner_dialog);
目前这段函数是放在onCreateDialog里。对话框正常。
布局什么的一切正常,加了这段函数就gg。
网上的那些解决方案都没用。
其实我的等级是常年签到出来的。
就是这样。
2017年03月28日 15点03分 1
level 12
星空雨灵 楼主
2楼
2017年03月28日 15点03分 2
level 11
截图代码和报错Log
2017年03月28日 15点03分 3
没有报错,就是打开对话框的时候闪退。代码图在楼下
2017年03月28日 22点03分
level 13
dislog.findViewById
2017年03月28日 16点03分 4
dialog.
2017年03月28日 16点03分
dialog不能跟这段函数...
2017年03月28日 22点03分
@星空雨灵 截图
2017年03月28日 22点03分
2017年03月29日 00点03分
level 12
星空雨灵 楼主
2017年03月28日 22点03分 5
level 10
我发现问题了[滑稽]
2017年03月28日 23点03分 6
应该是 Spinner spinner = (Spinner) dclayout.findViewById(R.id.spinner_dialog); 才对。
2017年03月28日 23点03分
2017年03月29日 00点03分
[真棒][玫瑰]
2017年03月29日 13点03分
@星空雨灵 百度一下Android自定义Dialog你就会发现这个问题
2017年03月29日 13点03分
level 13
原来用的是AlertDialog.Builder.setView(),
我还以为是Dialog.setContentView()
2017年03月29日 00点03分 7
level 11
dclayout.findv
2017年03月29日 04点03分 8
[玫瑰]
2017年03月29日 13点03分
level 9
同上,findviewById方法只能找到main的控件id,其他的必须要view.findViewById
2017年03月29日 23点03分 9
1