在活动创建失败时显示弹出窗口

拉杰夫·库马尔

我想表明popupactivity on create()方法,但似乎没有要发生的。没有exceptionpopup

以下是代码

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    btnClear = (Button)findViewById(R.id.btnClear);
    txtPassword = (TextView) findViewById(R.id.txtPassword);
    txtPassword.setOnTouchListener(otl);
    btnClear.setVisibility(View.GONE);
    objDBHelper = DBHelper.getInstance(getApplicationContext());
    SQLiteDatabase db = objDBHelper.getWritableDatabase();
    long driverProfileCount = objDBHelper.getProfilesCount(db);

        initiatePasswordPopupWindow(); // show pop up when no data is in table

}

 private void initiatePasswordPopupWindow() {
    try {
        //We need to get the instance of the LayoutInflater, use the context of this activity
        LayoutInflater inflater = (LayoutInflater) Login.this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        //Inflate the view from a predefined XML layout
      final  View layout = inflater.inflate(R.layout.setting_password_popup,
                (ViewGroup) findViewById(R.id.setting_password_popup_element));
        // create a 300px width and 470px height PopupWindow
        pw = new PopupWindow(layout, 600, 720, true);
        // display the popup in the center
        layout.post(new Runnable() {
            public void run() {
                pw.showAtLocation(layout, Gravity.CENTER, 0, 0);
                Button cancelButton = (Button) layout.findViewById(R.id.end_data_send_button);
                cancelButton.setOnClickListener(cancel_button_click_listener);
            }
        });

       /* TextView mResultText = (TextView) layout.findViewById(R.id.server_status_text);*/


    } catch (Exception e) {
        e.printStackTrace();
    }
}

我缺少什么?

KB0

您尝试使用post不启动其消息队列的视图(PopupWindow 布局)。尝试使用已经在活动中的视图,例如根视图 - 更改layout.post(new Runnable() {findViewById(android.R.id.content)

findViewById(android.R.id.content).post(new Runnable() {
    public void run() {
        pw.showAtLocation(layout, Gravity.CENTER, 0, 0);

        Button cancelButton = (Button) layout.findViewById(R.id.end_data_send_button);
        cancelButton.setOnClickListener(cancel_button_click_listener);
    }
});

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

活动开始时显示弹出窗口

来自分类Dev

当adblock处于活动状态时显示弹出窗口

来自分类Dev

单击时显示弹出窗口

来自分类Dev

如何在活动中显示弹出窗口?

来自分类Dev

显示弹出窗口时将灰色应用于不活动的屏幕

来自分类Dev

推送通知时显示活动/弹出窗口,而不是状态栏中的消息

来自分类Dev

仅在诺言处于活动状态时如何显示和隐藏弹出窗口?反应

来自分类Dev

显示弹出窗口时将灰色应用于不活动的屏幕

来自分类Dev

在进行多个活动时如何在退出android中的应用时创建弹出窗口进行确认

来自分类Dev

LDAP 身份验证失败时无法显示模式弹出窗口

来自分类Dev

如何从ViewModel创建和显示弹出窗口

来自分类Dev

满足PHP条件时显示弹出窗口

来自分类Dev

在悬停而不是单击时显示弹出窗口

来自分类Dev

单击按钮时未显示弹出窗口

来自分类Dev

使用mysqli时不显示弹出窗口

来自分类Dev

在显示时获取jQuery弹出窗口的高度

来自分类Dev

显示弹出窗口时GIF动画停止

来自分类Dev

在悬停而不是单击时显示弹出窗口

来自分类Dev

Excel导入失败时显示弹出消息

来自分类Dev

弹出窗口处于活动状态时禁用滚动

来自分类Dev

在打开另一个弹出窗口时如何隐藏活动弹出窗口?

来自分类Dev

弹出窗口失败

来自分类Dev

显示弹出窗口时显示ArcGis 4.0 Javascript API事件

来自分类Dev

在传单地图中,加载大的JavaScript文件时不显示弹出窗口(作为L.Handler创建)

来自分类Dev

Powershell显示弹出窗口,并在循环时保持更新弹出窗口的主体

来自分类Dev

弹出窗口不显示

来自分类Dev

弹出窗口未显示

来自分类Dev

弹出窗口显示IllegalStateException

来自分类Dev

如何显示弹出窗口

Related 相关文章

热门标签

归档