Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText in PopupWindow not showing keyboard even if setFocusable(true)

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 .

like image 603
yhunz_19 Avatar asked Feb 15 '14 05:02

yhunz_19


People also ask

How do I get the EditText above my keyboard?

After research I figured out that to work in some cases parent layout has to be set android:fitsSystemWindows="true" . Then native functionality of scrolling EditText above scrollbar working like a charm. Show activity on this post. Simply setting android:fitsSystemWindows="true" in the layout xml worked for me.

How do I hide the soft keyboard on android after clicking outside EditText?

Ok everyone knows that to hide a keyboard you need to implement: InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm. hideSoftInputFromWindow(getCurrentFocus(). getWindowToken(), 0);

How do I show errors in EditText?

You can use the TextInputLayout to display error messages according to the material design guidelines using the setError and setErrorEnabled methods. In order to show the error below the EditText use: TextInputLayout til = (TextInputLayout) findViewById(R. id.


2 Answers

ha, .found the answer., just did

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

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

like image 157
yhunz_19 Avatar answered Oct 25 '22 06:10

yhunz_19


This worked for me:

popWindow.setFocusable(true);
popWindow.update();
like image 38
Kamleshwer Purohit Avatar answered Oct 25 '22 04:10

Kamleshwer Purohit