Question

In my app I want to use a theme which is defined in the framework-res.apk. I decompiled an other which uses this theme and I found this in the styles.xml

<style name="DefaultSettingsTheme" parent="@com.sonyericsson.uxp:style/SEMCTheme">
    <item name="android:directionality">leftToRight</item>
</style>

If I try to use this in my app it comes to an error because eclipse does not know that this theme is aviable in an other apk. How can I use this theme without rebuilding it?

Was it helpful?

Solution

I haven't tested this, but hope it works:

public class MyActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        String packageName = ""; // package name of the app of which you want to access the resources;
        String resourceName = ""; // name of the resource you want to access
        int theme = 0;

        theme = getResources().getIdentifier(resourceName, "style", packageName);

        if (theme != 0) {

            setTheme(theme);
        }
        setContentView(R.layout.main);

    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top