每次在对话框中设置textView的结果,应用会崩溃。对话框是通过链接包含textView的xml,并且这个textView就是需要更新的。AlertDialog.Builder alert = new AlertDialog.Builder(this);
LayoutInflater factory = LayoutInflater.from(this);
resultOne=(TextView)findViewById(R.id.resultOne); //resultone is a textview in xml dialog
resultOne.setText("hello"); //this code is making the app close
final View textEntryView = factory.inflate(R.layout.dialog, null);
alert.setView(textEntryView);
alert.show();
2 回答
阿波罗的战车
TA贡献1862条经验 获得超6个赞
调用顺序有问题,应该是调用
final View textEntryView = factory.inflate(R.layout.dialog, null);
resultOne=(TextView)textEntryView.findViewById(R.id.resultOne); //resultone is a textview in xml dialog
再去调用alert.setView(textEntryView);
添加回答
举报
0/150
提交
取消