【问题标题】:EditText in scroll view in androidandroid中滚动视图中的EditText
【发布时间】:2011-06-21 04:18:53
【问题描述】:

我尝试从应用程序创建一个,在应用程序中我有一个很长的表单,我想在滚动视图中显示,但是当我将 EditText 添加到滚动视图时 ..eclipse 在其设计器视图中显示了一些错误。

error!
IllegalStateException: ScrollView can host only one direct child
Exception details are logged in Window > Show View > Error Log

有没有人想办法破解?


在得到上述问题的解决方案后,我已包含此代码..!

现在 EditText 没有显示任何键入的文本,它只是给出了一些建议......!

我有以下 XML:

<ScrollView
android:id="@+id/widget64"
android:layout_width="320px"
android:layout_height="358px"
android:fillViewport="true"
android:isScrollContainer="true"
android:saveEnabled="true">
<TableLayout
android:id="@+id/widget58"
android:layout_width="320px"
android:layout_height="65px"
android:orientation="vertical"
>
<TableRow
android:id="@+id/widget60"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/user"
android:text="User"
android:textColor="#000000">
</TextView>
</TableRow>
<TableRow
android:id="@+id/widget60"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
>
<EditText
android:id="@+id/users_first_name" 
android:layout_height="fill_parent" 
android:layout_width="fill_parent" 
android:hint="First Name"
android:focusable="true"
android:inputType="textPersonName"
android:enabled="true"
android:ems="15">
</EditText>
</TableRow>
</TableLayout>
</ScrollView>

发现问题..... 我的模拟器键设置为中文而不是英文...

【问题讨论】:

    标签: android android-edittext


    【解决方案1】:

    首先将任何布局添加到该滚动视图,然后将编辑文本添加到该布局。然后自动获得该编辑文本的滚动。例如:将线性布局添加到该滚动视图,然后将编辑文本添加到线性布局。

    【讨论】:

    • 点击左上角
    【解决方案2】:

    是的,ScrollVew 只能有一个孩子。 为此做这样的事情

    <ScrollView
       fillViewPortView = "true">
    
        <RelativeLayout>
              // Design the entire layout in here
              // Put your elements one below the other. It will automatically scroll
              // dont forget to setFillViewPort view to true in ScrollView
        </RelativeLayout>
    </ScrollView>
    

    这肯定会解决问题
    希望他的帮助:)

    【讨论】:

    • 谢谢它的工作..:) 拯救了我的一天...@User333 和@Javanator
    • 如果有帮助 通过选择左侧的检查来接受答案。它也会帮助其他人
    • 现在键入的文本没有出现在 EditText..!
    • 您是否正在查看编辑文本,但在按下软键盘的键后无法看到其中的文本。如果是这样。然后检查您可能已更改的文本颜色。在布局中放置一个简单的默认编辑文本,无需任何修改进行测试。让我知道结果
    • 是的......!有建议来了..但它们是中文或日文的....
    猜你喜欢
    • 1970-01-01
    • 2014-06-12
    • 1970-01-01
    • 2015-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-15
    相关资源
    最近更新 更多