如何使用LayoutInflater吹气? [英] How do use the LayoutInflater inflater?

查看:131
本文介绍了如何使用LayoutInflater吹气?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚创建用java code不仅没有从XML布图设计布局设计。
像下面的

I just create the Layout design using java code only not from the XML Layout Designs. Like the following

 LinearLayout llay=new LinearLayout(this);

TextView tv1=new TextView(this);
tv1.setText("New Layout");
llay.addView(tv1);

如何使用LayoutInflater吹气我的LinearLayout?我是新来的Andr​​oid

How do use the LayoutInflater inflater for my LinearLayout ??? I am new to Android

推荐答案

LayoutInflater 被用来获取和分裂通过XML在code定义的布局。我想说的是,基本上是你当然如果你通过Java code定义布局,就像你贴不需要布局膨胀。

The LayoutInflater is used to get and split a layout defined via XML in your code. What I want to say is basically that you certainly don't need layout inflating if you define your layout via Java code like you've posted.

如果你想通过你的的LinearLayout 作为内容视图然后将其设置在喜欢你的的onCreate()方法这一点。

If you want to pass your LinearLayout as your content view then set it in your onCreate() method like this.

setContentView(llay);

这篇关于如何使用LayoutInflater吹气?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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