在Android的动态更改内部景观景观 [英] Dynamically change view inside view in Android
问题描述
我有这个RelativeView与3单选按钮在上面。我想改变视图的底部,当用户点击按钮中的一个。
I have this RelativeView with 3 radiobuttons on top. I want to change the bottom part of the view when the user clicks on one of the buttons.
蓝色部分是我想加载不同意见的地方。
The blue part is the place i want to load different Views in.
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == iVerzekeringen){
layout.removeView(body); // THIS PART IS
layout.addView(testview); // NOT WORKING
}
else if (checkedId == iPersoonlijk){
}
else if (checkedId == iNotities){
}
}
我如何可以加载不同的看法变成了蓝色的部分?
How can i load different Views into the blue part?
推荐答案
我有点找到了答案:
layout = (RelativeLayout)findViewById(R.id.rellayout);
LayoutInflater layoutInflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout.addView(layoutInflater.inflate(R.layout.gegevens_verzekeringen, group, false), 1 );
这将加载景色父XML。我希望它加载了刚才的身体部分(蓝色部分的图片)
This loads the view over the parent xml. I want it to load it over just the 'body' part (the blue part in the picture)
我申报的身体是这样的:
I declared the body like this:
body = (RelativeLayout)findViewById(R.id.body);
但是当我做 body.addView(layoutInflater.inflate(R.layout.gegevens_verzekeringen,组,FALSE),1);
据最高审计机关 java.lang.IndexOutOfBoundsException:指数= 1数= 0
我怎样才能解决这个问题?
How can i fix this?
编辑:明白了:
body.addView(layoutInflater.inflate(R.layout.gegevens_verzekeringen, null));
这篇关于在Android的动态更改内部景观景观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!