【发布时间】:2013-10-23 11:19:10
【问题描述】:
buttCalc.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
EditText val1 = (EditText)findViewById(R.id.edit1);
EditText val2 = (EditText)findViewById(R.id.edit2);
EditText risultato = (EditText)findViewById(R.id.risultato);
Bundle bundle = new Bundle();
bundle.putString("Valore2", val2.getText().toString());
risultato.setText(bundle.getString("Valore2"));
大家好,当我单击该按钮时,我的应用程序在 vm 中崩溃,我想: 1 点击按钮 2 risultato 文本框 = val2 文本
先谢谢你
【问题讨论】:
-
设置文本为什么需要捆绑?
risultato.setText(val2.getText().toString())就够了 -
按钮的 findviewbyid 完成了吗?
-
你有一些 ID 问题,你的代码工作正常。
-
需要更多代码+ logcat..
-
@kalyanpvs 我不认为它在按钮单击中进行编辑文本初始化会导致 NPE。并且 setText 可以取 null grepcode.com/file/repository.grepcode.com/java/ext/…
标签: android button textbox crash bundle