android - Using keyboard with stateAlwaysVisible, after touch any letter the showed AlertDialog opens selected, why? -


I have only one button in my layout 10 activity after count of (five keyboard touch) a alertcard . To show the keyboard, windowSoftInputMode = "stateAlwaysVisible"

After touching the problem, any key on the keyboard is only one button: the activity on the manifest is android. Selected. In the blue, the entire button is like "Highlighted".

I can use the code at the bottom of the layout to solve the button problem:

  android: focusable = "true" android: focusableInTouchMode = "true" / Code>  

but for AlertDialog , it will open when selected.

Also with AlertDialog , it opens with a button.

But I do not want this behavior, how can I avoid it?

Below are my code:

Clear:

& amp; Activity Activity: Android: Name = "Main Activitist" Android: windowSoftInputMode = "stateAlwaysVisible" & gt; & Lt; / Activity & gt;

Activity:

  public class extends the main Gtividhitakt activity (stable Int count = 0; @ Override protected void saved create (bundled Instansstet) {Suprknkret (saved Instensstet); setContentView (R.layout.activity_main_activity_test);} @ override public boolean Dispatch Kiaavent (Kiivent event) {count + = 1; log d. ( "Count", "Count:" + Calculation); if (calculation> = 10) {count = 0; InputMethodManager inputManager = (InputMethodManager) getSystemService (activity.INPUT_METHOD_SERVICE); Inp utManager.hideSoftInputFromWindow (getCurrentFocus (). GetWindowToken (), 0); AlertDialog.Builder builder = new AlertDialog.Builder (this); builder.setTitle ( "title"); builder.setMessage ( "message"); builder.setPositiveButton ( R.string.yes, new DialogInterface.OnClickListener () {public void onClick (DialogInterface dialog, int which) {dialog.dismiss ();}}); builder.setNegativeButton (R.string.no, new DialogInterface.OnClickListener () {Public Zero onClick (DialogInterface dialog, integer which) {dialog.dismiss (); Finish ();}}); Builder.setOnCancelListener (New OnCanLeister () {@Override Cancel at Public Zero (DialogInterface Dialog) {dialog.dismiss (); finish ();}}); AlertDialog Warning = Builder.Create (); Alert.show (); } Return super.dispatchKeyEvent (event); }}  

Layout:

  & lt; LinearLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Layout_width = "match_parent" Android: layout_height = "match_parent" & gt; & Lt; Button android: id = "@ + id / bt_testButton" Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" android: text = "button" / & gt; & Lt; / LinearLayout & gt;  

This view focus problem is that you can solve it with the method below.

Change your code:

  AlertDialog Warning = Builder.Create (); Alert.show ();  

From:

  Last AlertDialog Warning = Builder.Create (); alert.setOnShowListener (New OnShowListener () {@Override public void onShow (DialogInterface dialog) {ViewParent parents = alert.getButton (AlertDialog.BUTTON_POSITIVE) .getParent (); if (ViewGroup instanceof parent) {ViewGroup VG = (ViewGroup) Parents; Vg.setFocusable (true); vg.setFocusableInTouchMode (true); vg.requestFocus ();}}}); Alert.show ();  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -