在Android中动态更新TextView [英] dynamically update TextView in Android
本文介绍了在Android中动态更新TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对 Android 开发很陌生.有人可以让我知道动态更新 TextView
(或整个屏幕)的相关 API 吗?
I am quite new to Android development. Can someone let me know the relevant APIs to dynamically update a TextView
(or entire screen )?
例如:我有一个搜索应用程序,我需要在找到结果时显示结果,而不是等待所有结果然后显示.
For example: I have a search application and I need to show the results as they are found rather than waiting for all results and then show.
推荐答案
有几个步骤,你没有提到你知道多少与你不知道多少.
There are a few steps and you didn't mention how much you know versus how much you don't.
假设您的 UI 初始结构是在 res/layout 中定义的,并且它在您的活动中的某处包含一个 TextView:
Assuming your UI initial structure is defined in the res/layout and it includes a TextView somewhere, in your activity:
public void updateTextView(String toThis) {
TextView textView = (TextView) findViewById(R.id.textView);
textView.setText(toThis);
}
这篇关于在Android中动态更新TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文