[英]when focus EditText ,EditText didnot pop out the SoftKeyboard
是的。這是我的問題。當我在布局中使用edittext時。當我聚焦或觸摸Edittext時,它們沒有彈出軟鍵盤。
這是我的布局:
```
<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>
現在,我沒有在Java類文件中編寫任何代碼
我嘗試了網絡告訴我們的所有方式,但都失敗了。 這是我測試的方式: android:windowSoftInputMode="stateVisible"
添加到Mainifest中的Activity ---->失敗
它彈出軟鍵盤,但指向類的指針,而不是edittext
等等...
有人幫我解決問題。
從LinearLayout中刪除android:descendantFocusability="blocksDescendants"
。 我嘗試了您的代碼,它起作用了。
希望能幫助到你。
編輯:
Explaination:
屬性android:descendantFocusability="blocksDescendants"
只是阻塞您的LinearLayout
以將焦點集中在android:descendantFocusability="blocksDescendants"
視圖上。
的Decendants LinearLayout
=的所有子視圖LinearLayout
你可以試試看
<activity
android:name="Activity"
android:windowSoftInputMode="adjustPan"/>
在要顯示鍵盤的位置使用此代碼(可能在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.