我该如何解决这个错误? [英] How Can I Solve This Error ?

查看:62
本文介绍了我该如何解决这个错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试按照android教程但在尝试运行代码后出现此错误。此代码在我的MainActivity中。



  public   void  sendMessage(View view){
Intent intent = new Intent( this ,DisplayMessageActivity。 class );
EditText editText =(EditText)findViewById(R.id.edit_message);
String message = editText.getText()。toString();
intent.putExtra(EXTRA_MESSAGE,message);
startActivity(intent);
}





但ERRoR在这条线上



 EditText editText =(EditText)findViewById(R.id.edit_message); 





无法解决R.id.edit_message

解决方案

我解决了它:)))))))))



i shuold在activity_main.xml中添加此行



@ + id / edit_message



但在tutrial中没有使用这一行


在该xml文件中给出的cheack editbox名称是相同与否,或者如果两者都不匹配则发送或不发送并发现此类型错误

I tried to follow the android tutorial but after I try to run the code this error appears. this code is in my MainActivity.

public void sendMessage( View view ){
    Intent intent = new Intent(this, DisplayMessageActivity.class);
    EditText editText = (EditText)findViewById(R.id.edit_message);
    String message = editText.getText().toString();
    intent.putExtra(EXTRA_MESSAGE,message);
    startActivity(intent);
}



but ERRoR is on this line

EditText editText = (EditText)findViewById(R.id.edit_message);



can not solve "R.id.edit_message"

解决方案

i solved it :)))))))))

i shuold add this line in activity_main.xml

"@+id/edit_message"

but in tutrial didn't use this line


cheack editbox name is given in that xml file both are same or not or mantion or not if both are mismatch and find this type error


这篇关于我该如何解决这个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆