0

是否可以在 android 中将 AdapterView 与文本字段一起使用?

我的查询返回一组值,并且我想将每个值放在一个文本字段中,以便用户可以编辑该值。

另外,我想单击一个按钮来创建一个新的空字段,以便我可以插入一个新条目。

如果你知道好的例子,那么请告诉我!

编辑 1

我更喜欢使用 XML 来定义 ui,我发现了这些信息:

“在这种情况下,我们创建了一个名为 text1 的新 id。id 字符串中 @ 后面的 + 表示如果该 id 尚不存在,则应自动将其创建为资源,因此我们动态定义 text1,然后使用它。” 来源http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html

这 + 是否允许我根据需要自动创建尽可能多的字段?有没有一种方法可以通用地指定 XML 中的布局,然后根据 db 响应创建临时字段?

非常感谢,

密斯

4

1 回答 1

0

Is it possible to use AdapterView with text fields in android?

Yes. It will be complex for you (and possibly also for the user), so I would not recommend it unless you have a few months' Android programming experience, but it should work.

Also, I want to click a button to create a new empty field, so that I may insert a new entry.

That will get a little complicated.

Will this + allow me to autocreate as many fields as needed?

No, that is not how you use ListAdapters for ListView rows.

Is there a way I can generically specify the layout in XML and then create fields adhoc based on db response?

Use a CursorAdapter.

Here is a free excerpt from one of my books that describes creating custom adapter classes. Here is a sample project that shows creating a custom CursorAdapter to display the results of a database query.

于 2010-06-02T22:07:30.457 回答