简体   繁体   English

从数据库中提取数据到android studio上的文本字段中

[英]Extracting data from database onto a text field on android studio

I have an app, and what I'm trying to do, is extract a single piece of data into a text field. 我有一个应用程序,而我想做的是将单个数据提取到文本字段中。 For example: 例如:

应用程式文字栏位的图片

In that image, I have a label called tariff, and adjacent to it, I have a textview field. 在该图像中,我有一个名为“关税”的标签,并且在它旁边,有一个textview字段。 I want to be able to draw the tariff name from my database into that field. 我希望能够将关税名称从数据库中提取到该字段中。

I've looked at all other tutorials and they usually involve a button, that has to be clicked on in order for data from the database to be extracted. 我看过所有其他教程,它们通常都包含一个按钮,必须单击该按钮才能从数据库中提取数据。

Note: Prior to arriving at this activity of the app, a user must log into the app, a user is associated to a tariff name. 注意:在进行该应用程序的此活动之前,用户必须登录该应用程序,该用户已与关税名称相关联。 I basically want to upload a tariff name based on the username onto textviewt . 我基本上想将基于用户名的关税名称上传到textviewt

I hope that makes sense. 我希望这是有道理的。 Please do let me know if you have any further questions regarding this. 如果您对此还有其他疑问,请告诉我。

I would really appreciate if someone could help me understand what I need to do to achieve this. 如果有人可以帮助我了解实现此目标所需的工作,我将非常感激。

Thanks in advance to those who have read the post! 在此先感谢那些阅读过这篇文章的人!

You can transfer data between activities by passing an Intent to the startActivity(Intent) method. 您可以通过将Intent传递给startActivity(Intent)方法在活动之间传输数据。 In your case the Intent would contain the username that was passed in by the user and with that username you can upload the tariff name. 在您的情况下,“意图”将包含用户传递的用户名,您可以使用该用户名上载关税名称。

You can use the onCreate() method if you need to get data from the database without the user clicking on a button. 如果需要从数据库获取数据而无需用户单击按钮,则可以使用onCreate()方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM