android中未打开软键盘

android中未打开软键盘,android,android-edittext,android-keypad,android-input-method,Android,Android Edittext,Android Keypad,Android Input Method,我是android的新手,正在开发一个演示应用程序,因为我有一个活动在屏幕顶部包含一个edittext,并希望在活动开始时显示键盘。我尝试了很多方法,但都不管用,有没有人能帮我整理一下 layout.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width=

我是android的新手,正在开发一个演示应用程序,因为我有一个活动在屏幕顶部包含一个edittext,并希望在活动开始时显示键盘。我尝试了很多方法,但都不管用,有没有人能帮我整理一下

layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/linearLayout"
    android:orientation="vertical" >

    <RelativeLayout
        android:id="@+id/rl_hdr"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#16BBA1"
        android:gravity="center_vertical"
        android:padding="10dp">

        <ImageView
            android:id="@+id/iv_back"
            android:layout_width="25dp"
            android:layout_height="22dp"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="0dp"
            android:src="@drawable/ic_back_white" />

        <EditText
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:textColorHint="#939393"
            android:singleLine="true"
            android:layout_centerInParent="true"
            android:hint="Search"
            android:layout_marginLeft="5dp"
            android:padding="5dp"
            android:gravity="center_vertical"
            android:drawablePadding="5dp"
            android:layout_marginRight="5dp"
            android:textSize="16dp"

            android:imeOptions="actionDone"
            android:cursorVisible="true"
            android:layout_toRightOf="@+id/iv_back"
            android:drawableRight="@drawable/ic_search"
            android:background="@drawable/bg_et_actionbar"
            android:id="@+id/et_search" />


    </RelativeLayout>

       <FrameLayout
            android:id="@+id/fragmentTimeline"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"

            android:layout_marginTop="0dp" />

</LinearLayout>
<activity
            android:name="one.tusk.stush.SearchPostActivity"
            android:label="Back"
            android:parentActivityName="one.tusk.stush.activities.MainActivity"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateAlwaysVisible" >
            >
        </activity>

你必须把焦点放在编辑文本上。试试看

android:focusable="true"
在编辑文本中,它将打开软键盘

尝试将您的清单更改为

android:windowSoftInputMode="stateVisible"
而不是

android:WindowsofInputMode=“StateAllwaysVisible”

如果问题仍然存在,请尝试使用编程方式打开它

InputMethodManager imm = (InputMethodManager)getSystemService(
    Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mEditText, 0);

您也可以参考SO

布局xml post it在哪里?@MD-请检查我的更新问题,我已经在
编辑文本中添加了布局。do
focus enabled=true
编辑文本中添加了,但没有发生任何事情。或者在java类文件中设置edittext focus没有发生任何事情。我已经在edittext中添加了行(@sulfuricacid请尝试更新的答案。我已在oncreat中手动添加了此代码,但没有任何效果。@sulfuricacid您是否尝试过android:WindowsOfInputMode=“stateVisible”是尝试过。但没有发生任何事
InputMethodManager imm = (InputMethodManager)getSystemService(
    Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mEditText, 0);