Settings: PreviewPagerAdapter: copy the full theme

getThemeResId() returns the theme resource id which is defined inside AndroidManifest.xml.
If you set a theme via code (or add extra attributes using applyStyle method), the new theme will not be carried over.
Fix this by using setTo method with the context theme as argument.

Issue: https://issuetracker.google.com/37543358

Test: set new theme via code (or add extra attributes using applyStyle method) and check if they are carried over to the configContext context

Change-Id: I82739fe47b2d5b2d05da4cb3759b630b10dc8c8f
This commit is contained in:
Anas Karbila
2017-04-20 21:44:13 +09:00
committed by Anas Karbila
parent 31ec85a913
commit ada2ea57b4

View File

@@ -74,7 +74,7 @@ public class PreviewPagerAdapter extends PagerAdapter {
// Create a new configuration for the specified value. It won't
// have any theme set, so manually apply the current theme.
final Context configContext = context.createConfigurationContext(configurations[j]);
configContext.setTheme(context.getThemeResId());
configContext.getTheme().setTo(context.getTheme());
final LayoutInflater configInflater = LayoutInflater.from(configContext);
final ViewStub sampleViewStub = new ViewStub(configContext);