显示变量值时遇到问题
我刚刚尝试显示变量的值,但显示某种异常 这就是强制关闭。
我尝试过的代码
TextView myTextView = (TextView) findViewById(R.id.result9);
myTextView.setText("your score is " +count);
最初被认为是 count=0 。
任何人都可以建议我解决这个问题,
提前致谢
I have just tried to display the value of the variable but is showing some kind of exception
that is FORCE CLOSE.
the code i have tried is
TextView myTextView = (TextView) findViewById(R.id.result9);
myTextView.setText("your score is " +count);
considered count=0 intially.
Can any one suggest me for this problem
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果 myTexyView 在对话框中,您必须执行以下操作:
myTextView = (TextView)dialog.findViewById();
无论如何都要清理项目...有时会发生这种情况:
在 Eclipse 中:项目->清理->你的项目
if myTexyView is in dialog you have to do this:
myTextView = (TextView) dialog.findViewById();
anyway do clean project...this happens sometimes:
in eclipse: project->clean->your project
似乎
findViewById()
返回null
。这意味着当前布局中没有 ID 为result9
的小部件,或者您忘记了setContentView()
。Seems
findViewById()
returnsnull
. It means that either there's no widget with idresult9
in current layout or your forgot tosetContentView()
.请检查您设置的 xml,setContainView() 它必须具有带有“result9”此 id 的 TextView。
can please check your xml which one you have set, setContainView() it mast have TextView with "result9" this id.