本文介绍了从布局查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了这个 http://www.brighthub.com/mobile/google-android/article/48845.aspx
我知道我可以创建视图.但是我想定义一个布局xml并将其放到我的视图中.例如,在布局中,我将有一些textview,我将为它们动态设置值并将其添加以查看和显示.如果可以,这可能吗?如果没有其他选择?
i understand i can create a view. But i want to define a layout xml and put that into my view. for example in layout i will have a few textviews, i will set value to them dynamically and add them to view and display. is this possible if yes how ? if no whats the alternative ?
推荐答案
示例:
LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout dialerLayout = (LinearLayout) layoutInflater.inflate(R.layout.phone_dialer, null);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
dialerLayout.setLayoutParams(params);
LinearLayout tabDialer = (LinearLayout) findViewById(R.id.tabDialer);
tabDialer.addView(dialerLayout);
这篇关于从布局查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!