Hopefully this is easy to do, I've tried searching for it with no luck, my apologies if it was previously answered.
希望这很容易做到,我已经尝试过没有运气的搜索,如果之前已经回答我的道歉。
I want to be able to build 'blah' in setcontentview(R.layout.blah) as shown below in my code:
我希望能够在setcontentview(R.layout.blah)中构建'blah',如下面的代码所示:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.options_sounds);
Where options_sounds will be defined by a user selected spinner. I'd like to save it as a string and then read it into the setcontentview line somehow. All the blah.xml files will have been previously built and ready to go, I just want the user to tell me which one he/she wants.
其中options_sounds将由用户选择的微调器定义。我想将它保存为字符串,然后以某种方式将其读入setcontentview行。所有的blah.xml文件都已经预先构建好了,我只想让用户告诉我他/她想要哪一个。
Thank you for your time. -c
感谢您的时间。 -C
1 个解决方案
#1
0
You could use a switch statement and load the user's selection, since the layouts are already built and "ready to go".
您可以使用switch语句并加载用户的选择,因为布局已经构建并且“准备就绪”。
switch(layout_selection) {
case 1:
setContentView(R.layout.layout1);
break;
case 2:
setContentView(R.layout.layout2);
break;
}
#1
0
You could use a switch statement and load the user's selection, since the layouts are already built and "ready to go".
您可以使用switch语句并加载用户的选择,因为布局已经构建并且“准备就绪”。
switch(layout_selection) {
case 1:
setContentView(R.layout.layout1);
break;
case 2:
setContentView(R.layout.layout2);
break;
}