问题描述
|
将其添加到布局中后,将其充气并添加到另一个视图后将返回一个空布局
<View
android:layout_width=\"fill_parent\"
android:layout_height=\"1px\"
android:background=\"#e0e0e0\"/>
这是我给它充气的方式
LayoutInflater vi = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = vi.inflate(R.layout.stoplistitem,null);
if(dt != null && stop.getDescription() != null)
dt.setText(stop.getDescription());
if(st != null && stop.getStreet() != null)
st.setText(stop.getStreet());
if(mt != null && stop.getMunicipal() != null)
mt.setText(stop.getMunicipal());
if(idt != null && stop.getId() != null){
idt.setText(stop.getId().toString());
//编辑我可以看到视图,但是没有内容
解决方法
通过使用
inflate(int resource,ViewGroup root,boolean attachToRoot)
将此视图附加到ViewGroup上,并且attachToRoot = true,root是要在其上膨胀的组件