简体   繁体   中英

when focus EditText ,EditText didnot pop out the SoftKeyboard

Yes.It is my question.When I using edittext in my layout.when I focus or touch the Edittext,them didnot pop out the soft keyboard.

this is my layout:

```

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="blocksDescendants"
        android:focusable="false"
        android:orientation="vertical"
        android:weightSum="1.0" >

        <RelativeLayout
          ...........................
          ...........................
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:focusable="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:weightSum="1.0" >

            <EditText
                android:id="@+id/detail_query_txt"
                android:paddingTop="15dp"
                android:layout_alignParentTop="true"
                android:layout_width="fill_parent"
                android:layout_height="40dp"
                android:gravity="center"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:inputType="phone" >

                <requestFocus />
            </EditText>

            <Button
                android:id="@+id/detail_query_but"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/detail_query_txt"
                android:focusable="false"
                android:text="@string/word_query" />
        </RelativeLayout>
    </LinearLayout>

</ScrollView>

``` Now:I didnot write any code in my java class file

I try all the way the Network tell us,all it failed. this is the way i test: android:windowSoftInputMode="stateVisible" add to Activity in Mainifest ----> failed
it pop out the Soft keyboard,but pointer to class,not the edittext

and so on...
someone help me to solve the problem.

Remove android:descendantFocusability="blocksDescendants" from your LinearLayout. I tried your code, it worked.

Hope it helps.

EDIT :

Explaination:

the attribute android:descendantFocusability="blocksDescendants" simply blocks your LinearLayout to give focus to the decendant view .

Decendants of LinearLayout = all the child views of LinearLayout

You can try this..

    <activity
         android:name="Activity"
         android:windowSoftInputMode="adjustPan"/>

Use this code in the point where you want to display the keyboard (may be in oCreate?)

EditText mEditText= (EditText) findViewById(R.id.editTextName-);

    ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
        .showSoftInput(mEditText, InputMethodManager.SHOW_FORCED);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM