List of usage examples for android.content Context getThemeResId
@UnsupportedAppUsage public int getThemeResId()
From source file:com.android.settings.PreviewPagerAdapter.java
public PreviewPagerAdapter(Context context, boolean isLayoutRtl, int[] previewSampleResIds, Configuration[] configurations) { mIsLayoutRtl = isLayoutRtl;//from ww w . jav a 2 s .co m mPreviewFrames = new FrameLayout[previewSampleResIds.length]; mViewStubInflated = new boolean[previewSampleResIds.length][configurations.length]; for (int i = 0; i < previewSampleResIds.length; ++i) { int p = mIsLayoutRtl ? previewSampleResIds.length - 1 - i : i; mPreviewFrames[p] = new FrameLayout(context); mPreviewFrames[p].setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); for (int j = 0; j < configurations.length; ++j) { // 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()); final LayoutInflater configInflater = LayoutInflater.from(configContext); final ViewStub sampleViewStub = new ViewStub(configContext); sampleViewStub.setLayoutResource(previewSampleResIds[i]); final int fi = i, fj = j; sampleViewStub.setOnInflateListener(new OnInflateListener() { @Override public void onInflate(ViewStub stub, View inflated) { inflated.setVisibility(stub.getVisibility()); mViewStubInflated[fi][fj] = true; } }); mPreviewFrames[p].addView(sampleViewStub); } } }