Monday 15 April 2013

android - DialogFragment and force to show keyboard -


I have a problem with my dialogue. So to make up my mind, I use the method described on the Android blog. Here's my DialogFragment

  @Override public view onCreateView (LayoutInflater inflater, ViewGroup container, bundle savedInstanceState) {final scene myLayout = inflater.inflate (R.layout.dialog_connect, null); Edit = (edit text) myLayout.findViewById (R.id.password_edit); Edit.requestFocus (); GetDialog () GetWindow () setSoftInputMode (LayoutParams.SOFT_INPUT_STATE_VISIBLE) .. Make me return; }   

If I use it on Creative (), then it works, but I would like to create an AlterDialog and to do this, I have the following code: Override

  @Public Dialogue Crack Diagnose (Bundle Saved InstantState) {AlertDialog. Builder Builder = New AlertDialog Builder (getActivity ()); // Set Layout for Flowers and Dialges // Remove tap as a parent view because the dialog is running in the Layout Builder. SetPositiveButton (R.string.ok, New DialogInterface.OnClickListener () {@Override public void onClick (DialogInterface dialog), int id) {callback.onYesConnectClick (edit.getText () toString ()) ;.}}) .setNegativeButton ( R.string.refuse, New DialogInterface.OnClickListener () {@Override Public Zero onClick (DialogInterface Dialog, Integer ID) {Callback.onNoConnectClick ();}}); Return builder.cent (); }   

If I comment on code from CodeCreateView (), then the app works, but I can not force the keyboard to show and if I disagree with the creatives () get me crash this stack trace:

  java.lang.RuntimeException: unable to start the activity ComponentInfo {com.test / com.test.ProfileActivity_}: android.util.AndroidRuntimeException : RequestFeature () content should be AndroidRuntime (android.app.ActivityThread.access $ 600 android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2362) androidRuntime android.app.ActivityThr ead.performLaunchActivity (ActivityThread.java:2312) is called before ActivityThread.java add AndroidRuntime: 156) AndroidRuntime android.app.ActivityThread at $ H.handleMessage (ActivityThread.java:1250) android.os.Handler.dispatchMessage ( Handler.java:99) AndroidRuntime (Looper.java on AndroidRuntime on android.os.Looper.loop: 137) AndroidRuntime android.app.ActivityThread.main (ActivityThread.java:5229) java.lang.reflect.Method.invokeNative (original Native method) at AndroidRuntime on AndroidRuntime (Method.java on java.lang.reflect.Method.invoke: 525) AndroidRuntime com.android.internal.os.ZygoteInit android.util at $ MethodAndArgs: Caller.run (ZygoteInit.java:799 ) Dalvik.system.NativeStart.main com.android.internal.os.ZygoteInit.main (ZygoteInit.java pictogram) on AndroidRuntime AndroidRuntime AndroidRuntime Reason Sector .AndroidRuntimeException: requestFeature () must be called before adding content   

So my question == & gt; Can I use alert dialogs and when the dialog appears, can I show the keyboard?

Override onactivated in your dialog and put getDialog () . GetWindow () SetSoftInputMode (LayoutParams.SOFT_INPUT_STATE_VISIBLE); in

No comments:

Post a Comment