Android 中滚动视图中的 EditText
我尝试创建一个应用程序,在应用程序中我有一个冗长的表单,我想将其置于滚动视图中,但是当我将 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>
发现了麻烦...... 我的模拟器密钥设置为中文而不是英文...
I try to create a from application, in the app I have a lengthy form which I want to be in a scroll view, But when I add EditText to the scrollView ..the eclipse shows some error in its designer view.
error!
IllegalStateException: ScrollView can host only one direct child
Exception details are logged in Window > Show View > Error Log
Any one have an idea to crack it out?
I have included this code after getting a solution for the above trouble..!
Now the EditText is not showing any typed text, it just gives some suggestions...!
I have the following 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>
Found the trouble.....
My emulator key was set to Chinese instead of English...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先将任何布局添加到该滚动视图,然后将 edittext 添加到该布局。然后自动获得该 edittext 的滚动。例如:将 Linearlayout 添加到该滚动视图,然后将 editText 添加到该线性布局。
First add any layout to that scrollview and then add edittext to that layout.Then automatically u got the scrolling for that edittext .For Ex:add Linearlayout to that scrollview and then add editText to taht linearlayout.
是的,
ScrollVew
只能有一个子项。为此,请执行以下操作
这肯定会解决问题
希望他的帮助:)
Yes,
ScrollVew
can have only one child.For this do something like this
This will solve the problem for sure
Hope his help : )