2013-08-23 31 views
0

我正在嘗試製作Hello World記事本應用程序,並且當前必須單擊我的EditText中的光標右鍵以調出軟鍵盤。我希望能夠點擊EditText中的任何位置來顯示鍵盤。單擊EditText中的任意位置以顯示鍵盤

這裏是我的佈局我的EditText聲明:

<EditText 
    android:id="@+id/text" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:inputType="text" > 
</EditText> 

編輯:

我使用的是Galaxy Nexus的模擬器,這裏是我所得到的:

screen

我必須點擊藍色標記上方的區域來獲取鍵盤。

+1

聽起來像是你的設備很奇怪。 EditText應該顯示鍵盤,無論你點擊它的內部 – dymmeh

+0

簽出[鍵盤沒有顯示,當我點擊在android的edittextview?](http://stackoverflow.com/questions/6977773/keyboard-not-shown-when-i -click-on-edittextview-in-android) –

回答

2

試試這個:下面的代碼

<EditText 
    android:id="@+id/text" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:inputType="text" > 
</EditText> 
+0

這是正確的答案。使用「wrap_content」,EditText視圖在開始時非常小(正如您在截圖中看到的那樣)。 layout_width =「match_parent」使得它跨越屏幕(如果父視圖這樣做的話)。將layout_height設置爲match_parent可能有點過分誇張,但肯定有效。 – Ridcully

2

用於顯示softkeyboard當你的EditText獲得焦點例如

youredittext.setOnFocusChangeListener(new OnFocusChangeListener() 
{ 

@Override 
public void onFocusChange(View v, boolean hasFocus) { 

if(hasFocus)         
{ 

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.showSoftInputFromInputMethod(youeedittext.getWindowToken(), 0); 

} 



} 



}); 

這將每次你的EditText gewt集中展示軟鍵盤...如果不工作,請在OnClick事件中爲您的edittext使用相同的代碼...

入住這AVD管理enter image description here

希望它可以幫助..

相關問題