如何动态地创建一个视图和机器人加上主视图? [英] How to dynamically create a view and add on main view in android?

查看:98
本文介绍了如何动态地创建一个视图和机器人加上主视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手(使用Eclipse在Mac)到Android。请让我知道如何动态创建一个视图,并把它添加到主视图。

I am newbie to android (on mac using eclipse). Please let me know how to create a view dynamically and add it to main view.

上下文:

其实我想显示处理的主屏幕上查看时,用户进行任何操作。

Actually I want to show a view of processing on the main screen when user has performed any action.

推荐答案

假设你的主要观点是的的ViewGroup ,你已经拥有它的实例的code会是这个样子:

Assuming that your main view is a ViewGroup and you already have an instance of it the code would look something like this:

TextView textView = new TextView(getContext());
textView.setText("Processing...");
mainView.addView(textView);

这篇关于如何动态地创建一个视图和机器人加上主视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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