2013-03-20 80 views
0

我有一个在充气xml中的按钮,我想要它的xml id。请帮我一些东西........ 我夸大了这样的东西。问题,同时在ANDROID中膨胀xml

RelativeLayout mainLayout = (RelativeLayout)findViewById(R.id.relative); 

//创建视图以膨胀layout_item(与之前创建的TextView的所述XML)

view = getLayoutInflater().inflate(R.layout.inflate, mainLayout,false); 

//添加视图到主布局

mainLayout.addView(view); 
+0

你的问题是什么?你需要从膨胀的布局中获得布局或视图吗?你可以使用view.findViewById(R.id.yourLayoutId); – Neil 2013-03-20 06:26:33

+0

@kavya你的问题是什么? – 2013-03-20 06:27:33

+0

问题在哪里? – ngesh 2013-03-20 06:27:50

回答

0

检查这代码

RelativeLayout mainLayout = (RelativeLayout)findViewById(R.id. relative); 
View childLayout = getLayoutInflater().inflate(R.layout.child); 
mainLayout.addView(childLayout);