我想打開軟鍵盤上的活動開始時,我發現機器人:windowSoftInputMode =「stateVisible」不工作
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:windowSoftInputMode'是'activity'元素/標籤屬性。 – Deucalion 2012-03-18 17:37:05
你是對的 - 我改變了。仍然沒有鍵盤。 – 2012-03-19 07:46:08
你做了什麼?它最終解決了嗎? – Kenji 2017-12-10 13:24:39