2013年12月4日星期三

android in the dialog pop-up soft keyboard problem

I show the activity in a dialog, in this dialog with an input box , click on the input box to enter .
I hope the input box after clicking out of the soft keyboard to enter data via the soft keyboard , but no pop-up soft keyboard , only physical keyboard input ,
have encountered this problem , help
------ Solution -------------------------- ------------------
not done this effect , but I can probably provide an idea:
First you have to click on the pop-up soft keyboard in the input box , then you have to first input box for you to register a click event listener : OnClickListener
Secondly, realize you want to complete the work within the listener , the Internet has many similar examples , like a landlord recommend :
http://aijiawang-126-com.iteye.com/blog/662088

I hope to help you
------ Solution ----------------------------- ---------------
calling view your dialog contained requestFocus () method
------ Solution --------- -----------------------------------
can control your display software disk

if(hasFocus){
((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).showSoftInput(view, 0);
}

------ eference ------------------------------------- -

trial in accordance with this method , and calls im.isActive soft keyboard after performing pop ( ) to determine the validity of the soft keyboard , the resulting value is false, horizontal screen , vertical screen under the same results.
------ eference --------------------------------------- < br>
this did not effect
------ eference ------------------------------- --------


Well theoretically feasible , and the second floor of the same idea , but the soft keyboard does not come out , so I was very tangled ==
------ eference - --------------------------------------
here to do their own thing , do not know if it is wrong
started my practice is to define a dialog, inherited from alertdialog, then all of the layout of the inside of his own writing , the button is also used imagebutton, unlike the above comes only display text ( requirements , no way ) , not bombs in this case how the soft keyboard.
The general custom dialog class are inherited from the dialog , layout, and where we can operate only the middle one , where I put a editview, you can pop up the soft keyboard , now proceed to modify the button layout right, hey . . .
Another problem encountered , and share , set editview in popupwindow in time, but also can not eject the soft keyboard , but you can get through requestfoucs functions can focus .

------ eference ------------------------------------ ---
Finally , to solve the problem
approach is: the layout has not changed , the layout of the dialog on by the layout to load
custom class is inherited from the dialog , and rewrite the constructor with an int , this parameter is used to load the dialog topics
then define the theme string.xml
code is as follows :
<style name="dialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item><!--边框 -->
<item name="android:windowIsFloating">true</item><!--是否浮现在activity之上 -->
<item name="android:windowIsTranslucent">false</item><!--半透明 -->
<item name="android:windowNoTitle">true</item>
<item name="android:background">@android:color/black</item>
<item name="android:windowBackground">@null</item>
<item name="android:backgroundDimEnabled">false</item><!--模糊 -->
</style>


------ eference ------------------------------------ ---
landlord, how to achieve ? did not understand Yeah , ask
------ eference ---------------- -----------------------
did not see is how to solve the problem
------ eference ----- ----------------------------------


Customize dialog, inherited from the Dialog class ( rather than alertdialog), when rewriting with constructor theme , then you want to generate dialog , using the constructor to construct a dialog .
theme code posted on the 8th floor .
------ eference --------------------------------------- < br>

my testing and understanding :

Let's Talk is AlertDialog, where the landlord 's solution is to abandon AlertDialog this layer , directly inherited Dialog ...

After my test , really OK. . . In fact , no theme landlord directly with Dialog default theme , the soft keyboard pops up normally . . Test code is as follows :
LayoutInflater inflater = (LayoutInflater) getSystemService (LAYOUT_INFLATER_SERVICE);
mLayout = (LinearLayout) inflater.inflate (R.layout.alert_add_new_member, null);

Dialog mDialog = new Dialog (CustomAlertDialog.this);
mDialog.addContentView (mLayout, new LinearLayout.LayoutParams (-2, -2));
mDialog.show ();

So, what with the landlord irrelevant . . .

However, the difference between the landlord and the default theme in theme :
true
default theme is no above this , the landlord added this . .

default theme given that no property , leading to the pop-up dialog box input method with some overlap , it is difficult to see .
add this attribute , the pop-up dialog box does not appear input method and overlap one last look , patchwork. . The experience very comfortable. .

So , we proposed a custom dialog , the best plus true






------ eference ------------------------------------ ---
make up :

1 do not need to customize a subclass inherits Dialog . . Dialog directly use the system on the line . . .
2 does not need to customize what the theme, the default theme on it . . . . . . . . . . . . . . . .

=========================== end quote === =========================

------ eference ------------------------------------ ---
just encountered this problem and found to this paste . I am also a custom Dialog inherited from AlertDialog, there is no way the pop-up soft keyboard , only changed one place , inherited from the dialog, the soft keyboard came out. I guess AlertDialog source code in itself has a soft keyboard is disabled because AlertDialog itself is not the input box , android intention is to allow us time to custom dialog inherited from Dialog.
------ eference --------------------------------------- < br> I went to google up , google says is very likely because of the XML EditText added a , get rid of it, you can use a method similar to the first reply , wrote in setOnFocusChangeListener inside , at least I was like ,
------ eference ----------------------------------- ----
or # 14 to say the phrase , put into inherited from AlertDialog inherited from Dialog on Ok, so we must solve the problem is simple, the top one !
------ eference --------------------------------------- < br> there is a way :
before calling the show method first call setView (layout), show after calling window.setContentView (layout), two Layout layout should be the same .

AlertDialog ad = new AlertDialog.Builder (context) create ().;
ad.setView (ManagerDialogLayout_.build (context, ad));
ad.show ();
Window window = ad.getWindow ();
window.setContentView (ManagerDialogLayout_.build (context, ad));
------ eference -------------------- -------------------
can read the official document : http://developer.android.com/reference/android/app/Dialog.html
One of the paragraphs :
ote:. Activities provide a facility to manage the creation, saving and restoring of dialogs See onCreateDialog (int), onPrepareDialog (int , Dialog), showDialog (int), anddismissDialog (int). If these methods are used, getOwnerActivity () will return the Activity that managed ; this dialog.

Often you will want to have a Dialog display on top of the current input method, because there is no reason for it to accept text. You can do this by setting theWindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM window flag (assuming your Dialog takes input focus, as it ; the default) with the following code:


getWindow (). setFlags (WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
Also: In order to prevent the pop-up input to the background behind the squeeze deformation , where you can add Manifest :
android: windowSoftInputMode = "adjustPan | stateHidden"

Hey I was so resolved !

没有评论:

发表评论