如何在android应用程序中自动填充编辑文本? [英] How to auto fill an edit text in android application?

查看:43
本文介绍了如何在android应用程序中自动填充编辑文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款安卓应用.我有一些产品和表格来购买该产品.在订单表格中,我有一个 Edit Text 作为 Product ( 意思是产品名称) .

I am developing one android application. In which I have some Products and form to purchase that product. In the Order form I have one Edit Text as Product ( means product name) .

在我的应用程序中,用户必须输入产品名称,但我想知道有什么方法可以EditText 字段会自动填充该特定产品,就像在活动翻车中一样.

In my application user has to type Product name but I want to know that Is there any way that the EditText field is autofilled with that particular Product like as in flipcart.

谁知道然后给我推荐...

Any one knows then suggest me...

提前致谢...

推荐答案

当你想填充它时,只需调用(在本例中从 XML 布局中读取它之后):

When you want to populate it just call (after reading it in from the XML layout in this example):

EditText myTextBox = (EditText) findViewById(R.id.editBox);
myTextBox.setText("My Product Description");

如果您正在寻找的是他们开始输入后的自动完成功能,那么 AutoCompleteTextView 是您最好的选择,它取代了 EditText 并提供了自动完成功能

If what you are looking for is an auto completion after they have started typing, then an AutoCompleteTextView is your best bet, replacing the EditText and providing the auto complete functionality

Android 开发者网站上有一个示例:http://developer.android.com/guide/topics/ui/controls/text.html#AutoComplete

There is an example of this over at the Android Developers website: http://developer.android.com/guide/topics/ui/controls/text.html#AutoComplete

这篇关于如何在android应用程序中自动填充编辑文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆