I'm trying to enable users to change layout of my apps.
This is my XML:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menuTheme"
android:orderInCategory="1"
android:showAsAction="never"
android:title="Theme">
<menu>
<item
android:id="@+id/themeBlack"
android:title="Black" />
<item
android:id="@+id/themeWhite"
android:title="White" />
</menu>
</item>
<item
android:id="@+id/menuAbout"
android:orderInCategory="1"
android:showAsAction="never"
android:title="About" />
Here are the screenshots from my emulator: This is my menu.
After clicking the item Theme under the menu, this submenu will appear.
Lets say i wish to add a white layout, where and how should i add codes?I have a XML file named themewhite.XML in the res/layout folder. I tried to add a switch in the item theme but it doesn't seemed to be correct.
This is my code:
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch(item.getItemId())
{
case R.id.menuTheme:
{
switch(item.getItemId())
{
case R.id.themeWhite;
{
setContentView(R.layout.themewhite);
}
}
break;
}
case R.id.menuAbout:
{
break;
}
}
return super.onOptionsItemSelected(item);
}