即使 setFocusable(true),PopupWindow 中的 EditText 也不显

EditText in PopupWindow not showing keyboard even if setFocusable(true)(即使 setFocusable(true),PopupWindow 中的 EditText 也不显示键盘)

本文介绍了即使 setFocusable(true),PopupWindow 中的 EditText 也不显示键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法完成这项工作.我已经将 popWindow 设置为可聚焦于我在其他论坛上阅读的内容,但仍然没有运气.

I can't seem to get this work. I already set popWindow focusable as to what I read on other forums but still no luck.

xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:background="@drawable/popbg"
android:orientation="vertical" >

<Button
    android:id="@+id/cancel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:layout_marginRight="10dp"
    android:layout_marginTop="30dp"
    android:background="@drawable/zcancel" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="10dp"
    android:text="SSID"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<EditText
    android:id="@+id/editText3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="textPersonName" />

java

 case(R.id.settings):
 switch (event.getAction()) 
 {
case MotionEvent.ACTION_DOWN:
v.setBackgroundResource(R.drawable.cpanel2);
return true;
case MotionEvent.ACTION_UP:
v.setBackgroundResource(R.drawable.cpanel1);

LayoutInflater layoutInflater =  
    (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);  

View popSwitchView = layoutInflater.inflate(R.layout.settings_xml, null);

final PopupWindow popWindow = new PopupWindow(popSwitchView);
popWindow.setWidth(LayoutParams.MATCH_PARENT);
popWindow.setHeight(LayoutParams.MATCH_PARENT);
popWindow.showAtLocation(popSwitchView, Gravity.CENTER, 0, 0);
popWindow.setOutsideTouchable(false);  
popWindow.setFocusable(true);
Drawable d = getResources().getDrawable(R.drawable.popbg); 
popWindow.setBackgroundDrawable(d);

Button CancelButton = (Button)popSwitchView.findViewById(R.id.cancel);

CancelButton.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
popWindow.dismiss();
}
});

                    popWindow.showAsDropDown(v, 50, -30);

                    return true;
                default:
                    return false;


            }

我正计划为网络配置创建一个设置弹出窗口.我似乎无法修复我的代码以便为你们提供良好的视图.

I'm planning on creating a popwindow of setting for network configurations. I can't seem to fix my code for a good view for you guys .

推荐答案

哈哈,找到答案了,刚刚做了

ha, .found the answer., just did

popWindow.setFocusable(true);
popWindow.update();

感谢您的支持!该主题的学分在android中单击edittextview时未显示键盘?

thanks for the support! credits from this topic Keyboard not shown when i click on edittextview in android?

这篇关于即使 setFocusable(true),PopupWindow 中的 EditText 也不显示键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:即使 setFocusable(true),PopupWindow 中的 EditText 也不显

基础教程推荐