Android 活动首次启动时无法启动创建弹出窗口
当我点击任何按钮调用show_popup时,它工作正常,但当我想要show_popup()调用onCreate()时,它不工作。我在logcat上看到了这样的错误显示Android 活动首次启动时无法启动创建弹出窗口,android,Android,当我点击任何按钮调用show_popup时,它工作正常,但当我想要show_popup()调用onCreate()时,它不工作。我在logcat上看到了这样的错误显示 protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.questi
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.question_layout);
show_popup();
}
private void show_popup(){
LayoutInflater lf = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View m_view = lf.inflate(R.layout.popup_question, null);
m_popup_window = new PopupWindow(m_view,500,150,false);
m_popup_window.showAtLocation(m_full_page, Gravity.CENTER, 0, 0);
}
请提前帮我谢谢 使用
处理程序对象显示弹出窗口
08-22 13:57:36.682: ERROR/AndroidRuntime(21860): at tesingimage.com.testingimagemain.show_pupup(testingimagemain.java:41)
08-22 13:57:36.682: ERROR/AndroidRuntime(21860): at tesingimage.com.testingimagemain.onCreate(testingimagemain.java:23)
08-22 13:57:36.682: ERROR/AndroidRuntime(21860): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
和onCreate()中的调用处理程序
在代码中,方法的名称是show_popup(),在logcat中是show_popup()。这是个错误吗?请发布完整的异常日志,而不仅仅是三条随机线
Handler hand = new Handler()
{
@Override
public void handleMessage(Message msg)
{
show_popup();
}
};
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.question_layout);
hand.sendEmptyMessage(0);
}