我的 Android 应用程序无法运行?
我试图制作应用程序,它正在工作,但现在当我在模拟器中运行它时,它甚至没有给我欢迎屏幕。代码:
public class TestArabActivity extends Activity {
/** Called when the activity is first created. */
TextView tvTop,tvBottom;
TableLayout tlStart;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome_screen);
//init variables
initVars();
}
private void initVars(){
tvTop = (TextView) findViewById(R.id.tv_start_TopTittle);
tvBottom = (TextView) findViewById(R.id.tv_strat_BottomTittle);
tlStart = (TableLayout) findViewById(R.id.tl_start);
}
}
我使用调试器并看到这些:
savedInstanceState
的值 =tvTop
、tvBottom
和tlStart
的 null 值也为空
为什么这些值为空?我知道这就是问题所在。
有人知道如何解决吗?谢谢。
I was trying to make application, it was working but now when I run it in emulator it's not even giving me the welcome screen. Code:
public class TestArabActivity extends Activity {
/** Called when the activity is first created. */
TextView tvTop,tvBottom;
TableLayout tlStart;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome_screen);
//init variables
initVars();
}
private void initVars(){
tvTop = (TextView) findViewById(R.id.tv_start_TopTittle);
tvBottom = (TextView) findViewById(R.id.tv_strat_BottomTittle);
tlStart = (TableLayout) findViewById(R.id.tl_start);
}
}
I used debugger and saw these:
- the value of
savedInstanceState
= null - values of
tvTop
,tvBottom
andtlStart
are null also
Why those values are null? I know this is the problem.
Anyone know how to solve it? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用DDMS来调试您的应用程序,如果它抛出任何异常,您可以从堆栈跟踪中看到问题来自哪里。如果它没有抛出任何异常。那么您可能忘记在菜单中声明意图过滤器:
Use DDMS to debug your application,if it throws any exception, you can see from the stack trace where the problem comes from. if it does not throw any exception. then probably you forgot to declear intent-filter in the menifest: