2014-06-17 96 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