简体   繁体   English

当焦点EditText时,EditText没有弹出软键盘

[英]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. 是的。这是我的问题。当我在布局中使用edittext时。当我聚焦或触摸Edittext时,它们没有弹出软键盘。

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 现在,我没有在Java类文件中编写任何代码

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 这是我测试的方式: android:windowSoftInputMode="stateVisible"添加到Mainifest中的Activity ---->失败
it pop out the Soft keyboard,but pointer to class,not the edittext 它弹出软键盘,但指向类的指针,而不是edittext

and so on... 等等...
someone help me to solve the problem. 有人帮我解决问题。

Remove android:descendantFocusability="blocksDescendants" from your LinearLayout. 从LinearLayout中删除android:descendantFocusability="blocksDescendants" 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 . 属性android:descendantFocusability="blocksDescendants"只是阻塞您的LinearLayout 以将焦点集中android:descendantFocusability="blocksDescendants"视图上。

Decendants of LinearLayout = all the child views of LinearLayout 的Decendants LinearLayout =的所有子视图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?) 在要显示键盘的位置使用此代码(可能在oCreate中?)

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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