use of android.view.LayoutInflater in project SmartTabLayout by ogaclejapan.
the class DemoTabWithNotificationMarkActivity method createTabView.
@Override
public View createTabView(ViewGroup container, int position, PagerAdapter adapter) {
LayoutInflater inflater = LayoutInflater.from(container.getContext());
Resources res = container.getContext().getResources();
View tab = inflater.inflate(R.layout.custom_tab_icon_and_notification_mark, container, false);
View mark = tab.findViewById(R.id.custom_tab_notification_mark);
mark.setVisibility(View.GONE);
ImageView icon = (ImageView) tab.findViewById(R.id.custom_tab_icon);
switch(position) {
case 0:
icon.setImageDrawable(res.getDrawable(R.drawable.ic_home_white_24dp));
break;
case 1:
icon.setImageDrawable(res.getDrawable(R.drawable.ic_search_white_24dp));
break;
case 2:
icon.setImageDrawable(res.getDrawable(R.drawable.ic_person_white_24dp));
break;
default:
throw new IllegalStateException("Invalid position: " + position);
}
return tab;
}
use of android.view.LayoutInflater in project VideoRecorder by qdrzwd.
the class Util method showDialog.
/**
* 公共弹窗
*
* @param context
* :Context 传入当前调用该方法的activity实例
* @param msg
* :String 要显示的显示文字
* @param type
* :int 显示类型1:仅为确定,2:有“确定”、“取消”两个操作
* @param handler
* :Handler 传入的需要回调的handler信息,可作为回调方法是用,msg.what = 1时为操作完成状态符
*/
public static void showDialog(Context context, String title, String content, int type, final Handler handler) {
final Dialog dialog = new Dialog(context, R.style.Dialog_loading);
dialog.setCancelable(true);
// 设置像是内容模板
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.global_dialog_tpl, null);
Button confirmButton = (Button) view.findViewById(// 确认
R.id.setting_account_bind_confirm);
Button cancelButton = (Button) view.findViewById(// 取消
R.id.setting_account_bind_cancel);
TextView dialogTitle = (TextView) view.findViewById(// 标题
R.id.global_dialog_title);
// 中竖线
View lineHoriCenter = view.findViewById(R.id.line_hori_center);
// 默认隐藏取消按钮
confirmButton.setVisibility(View.GONE);
lineHoriCenter.setVisibility(View.GONE);
TextView textView = (TextView) view.findViewById(R.id.setting_account_bind_text);
// 设置对话框的宽度
Window dialogWindow = dialog.getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
lp.width = (int) (context.getResources().getDisplayMetrics().density * 288);
dialogWindow.setAttributes(lp);
// 设置显示类型
if (type != 1 && type != 2) {
type = 1;
}
// 设置标题
dialogTitle.setText(title);
// 设置提示内容
textView.setText(content);
// 确认按钮操作
if (type == 1 || type == 2) {
confirmButton.setVisibility(View.VISIBLE);
confirmButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (handler != null) {
Message msg = handler.obtainMessage();
msg.what = 1;
handler.sendMessage(msg);
}
dialog.dismiss();
}
});
}
// 取消按钮事件
if (type == 2) {
cancelButton.setVisibility(View.VISIBLE);
lineHoriCenter.setVisibility(View.VISIBLE);
cancelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (handler != null) {
Message msg = handler.obtainMessage();
msg.what = 0;
handler.sendMessage(msg);
}
dialog.dismiss();
}
});
}
dialog.addContentView(view, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
// 点击返回键关闭
dialog.setCancelable(true);
// 点击外部关闭
dialog.setCanceledOnTouchOutside(true);
dialog.show();
}
use of android.view.LayoutInflater in project platform_frameworks_base by android.
the class CreateDirectoryFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
final ContentResolver resolver = context.getContentResolver();
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
final View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false);
final EditText editText = (EditText) view.findViewById(android.R.id.text1);
builder.setTitle(R.string.menu_create_dir);
builder.setView(view);
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
createDirectory(editText.getText().toString());
}
});
builder.setNegativeButton(android.R.string.cancel, null);
final AlertDialog dialog = builder.create();
// Workaround for the problem - virtual keyboard doesn't show on the phone.
Shared.ensureKeyboardPresent(context, dialog);
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView view, int actionId, @Nullable KeyEvent event) {
if ((actionId == EditorInfo.IME_ACTION_DONE) || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.hasNoModifiers())) {
createDirectory(editText.getText().toString());
dialog.dismiss();
return true;
}
return false;
}
});
return dialog;
}
use of android.view.LayoutInflater in project platform_frameworks_base by android.
the class TaskStackHorizontalViewAdapter method onCreateViewHolder.
@Override
public TaskStackHorizontalViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
ViewHolder viewHolder = new ViewHolder(inflater.inflate(R.layout.recents_tv_task_card_view, parent, false));
return viewHolder;
}
use of android.view.LayoutInflater in project platform_frameworks_base by android.
the class PreviewInflater method inflateWidgetView.
private View inflateWidgetView(WidgetInfo widgetInfo) {
View widgetView = null;
try {
Context appContext = mContext.createPackageContext(widgetInfo.contextPackage, Context.CONTEXT_RESTRICTED);
LayoutInflater appInflater = (LayoutInflater) appContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
appInflater = appInflater.cloneInContext(appContext);
widgetView = appInflater.inflate(widgetInfo.layoutId, null, false);
} catch (PackageManager.NameNotFoundException | RuntimeException e) {
Log.w(TAG, "Error creating widget view", e);
}
return widgetView;
}
Aggregations