本文整理汇总了Java中android.support.v7.internal.view.ContextThemeWrapper类的典型用法代码示例。如果您正苦于以下问题:Java ContextThemeWrapper类的具体用法?Java ContextThemeWrapper怎么用?Java ContextThemeWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContextThemeWrapper类属于android.support.v7.internal.view包,在下文中一共展示了ContextThemeWrapper类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDropDownViewTheme
import android.support.v7.internal.view.ContextThemeWrapper; //导入依赖的package包/类
public void setDropDownViewTheme(android.content.res.Resources.Theme theme)
{
if (theme == null)
{
mDropDownInflater = null;
return;
}
if (theme == mContext.getTheme())
{
mDropDownInflater = mInflater;
return;
} else
{
mDropDownInflater = LayoutInflater.from(new ContextThemeWrapper(mContext, theme));
return;
}
}
示例2: getAppCompActivity
import android.support.v7.internal.view.ContextThemeWrapper; //导入依赖的package包/类
/**
* Get AppCompatActivity from context
*
* @param context
* @return AppCompatActivity if it's not null
*/
public static AppCompatActivity getAppCompActivity(Context context) {
if (context == null) return null;
if (context instanceof AppCompatActivity) {
return (AppCompatActivity) context;
} else if (context instanceof ContextThemeWrapper) {
return getAppCompActivity(((ContextThemeWrapper) context).getBaseContext());
}
return null;
}
示例3: createDialog
import android.support.v7.internal.view.ContextThemeWrapper; //导入依赖的package包/类
public static AlertDialog createDialog(Activity activity, int type) {
ContextThemeWrapper wrapper = new ContextThemeWrapper(activity, android.R.style.Theme_Holo);
AlertDialog.Builder builder = new AlertDialog.Builder(wrapper);
LayoutInflater inflater = activity.getLayoutInflater();
switch (type) {
case LOADING_DIALOG:
builder.setView(inflater.inflate(R.layout.loading_dialog, null));
break;
case BACKUP_DIALOG:
builder.setView(inflater.inflate(R.layout.backup_dialog, null));
break;
case SAVING_DIALOG:
builder.setView(inflater.inflate(R.layout.saving_dialog, null));
break;
case INFO_DIALOG:
final SharedPreferences sharedPreferences = activity.getSharedPreferences(FragmentActivity.PREFERENCES_NAME, FragmentActivity.MODE_PRIVATE);
View view = View.inflate(activity, R.layout.info_dialog_view, null);
final CheckBox infoDialogCheckBox = (CheckBox) view.findViewById(R.id.infoDialogCheckBox);
builder
.setMessage(R.string.dialog_info_message)
.setView(view)
// .setView(view,16,16,16,16)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (infoDialogCheckBox.isChecked()) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(FragmentActivity.INFO_DIALOG_KEY, true);
editor.apply();
}
dialog.dismiss();
}
});
break;
}
return builder.create();
}