android:windowSoftInputMode =“stateVisible”不起作用

我想在Activity开始时打开软键盘,我发现了
android:windowSoftInputMode="stateVisible"

不起作用.

为了确保,我创建了一个新项目(认的“Hello world”)并执行了以下操作:

>将windowSoftInputMode添加到清单中.
>之后没有用,我在布局中添加一个EditView字段
>之后没有用,我补充说

getwindow().setSoftInputMode(WindowManager.LayoutParams.soFT_INPUT_STATE_ALWAYS_VISIBLE)
到onCreate程序.

我用Android2.3.3编译它并试图在我的galaxy S2设备和Android4模拟器上运行它
仍然 – 没有键盘.

我的清单文件

<?xml version="1.0" encoding="utf-8"?>
<uses-sdk android:minSdkVersion="9" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name">
    <activity
        android:name=".HelloworldActivity"
        android:label="@string/app_name"
        android:windowSoftInputMode="stateVisible">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

我的main.xml布局:

<?xml version="1.0" encoding="utf-8"?>
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello" />

<EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <requestFocus />

</EditText>

我的代码

public class HelloworldActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        getwindow().setSoftInputMode(WindowManager.LayoutParams.soFT_INPUT_STATE_ALWAYS_VISIBLE);

    }
}

解决方法

你使用认的Android键盘吗?如果你这样做,在不同的设备上试试,我知道它有一些问题

相关文章

这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...
这篇文章主要介绍“Android岛屿数量算法怎么使用”的相关知识...
本篇内容主要讲解“Android如何开发MQTT协议的模型及通信”,...
本文小编为大家详细介绍“Android数据压缩的方法是什么”,内...