2014-06-17 94 views
0

爲什麼我的EditText不可編輯?爲什麼我的EditText不可編輯?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/container" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/background" 
android:orientation="vertical" 
android:textAlignment="center" 
android:weightSum="2" 
tools:context="com.example.musicvideomaker.ProjectSettingsX" 
> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_marginTop="8dp" 
    android:text="Project Name" 
    android:textAppearance="?android:attr/textAppearanceLarge" /> 

<EditText 
    android:id="@+id/editText1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="30dp" 
    android:singleLine="true" > 

    <requestFocus /> 
</EditText> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_marginTop="50dp" 
    android:text="Save" /> 

</LinearLayout> 

我在模擬器中運行應用程序,我無法更改EditText。當我觸摸它時,鍵盤不會出現。我曾在多個模擬器上嘗試過。

回答

2

我不認爲它的代碼問題。我認爲它與模擬器本身有關。通常情況下,通常會使用計算機物理鍵盤的輸入,因此如果您不想這樣做,請嘗試在其上鍵入內容。 轉到AVD管理器,單擊您的設備,然後單擊編輯。 看到這個: 檢查/取消它根據您的需要。 enter image description here

+0

是的,當我這樣做時,鍵盤似乎顯示出來。 – iOSAaronDavid

+0

總是樂於幫助:) –

3

您的EditText是可編輯的,但您的模擬器可能沒有鍵盤支持。您需要編輯AVD以添加選項,如下所示:

  • 從Eclipse,轉到AVD Mananger。

  • 選擇特定的AVD,點擊Edit

  • 轉到硬件部分,單擊新建。

  • 選擇屬性名稱:鍵盤支持 默認情況下,它會添加一個值'no'。只需點擊值列,並將其更改爲「是」。

  • 再次點擊編輯AVD。

這將在config.ini文件中爲AVD添加屬性hw.keyboard=yes。它應該從那裏正常工作。

+0

我確定你知道你在做什麼,但我沒有看到這些選項。這可能是因爲我在運行Mac,我不確定。當我進行編輯時,我看到可以更改AVD名稱,設備,目標,CPU禁用,鍵盤:硬件鍵盤存在複選框,相機,內存選項,內存存儲,SD卡,仿真選項:快照和使用主機GPU複選框,禁用另一個複選框以覆蓋具有相同名稱的現有AVD。我沒有看到硬件部分。 – iOSAaronDavid

+0

我很高興其他職位幫助你。這可能是我們使用的Android工具版本的差異。 – bstar55