直播电商平台开发,底部弹窗,密码输入框,底部列表选择等
作者:互联网
直播电商平台开发,底部弹窗,密码输入框,底部列表选择等
导入依赖:
implementation 'com.lxj:xpopup:1.9.0'
implementation 'com.contrarywind:Android-PickerView:4.1.9'
public class DialogHelper {
public static void showConfirmDialog(Context context, String title, CharSequence content,
CharSequence cancelText, CharSequence confirmText, OnConfirmListener listener, OnCancelListener cancelListener) {
ConfirmDialog confirmDialog = new ConfirmDialog(context)
.setCancelText(cancelText)
.setConfirmText(confirmText)
.setTitleContent(title, content, null)
.setListener(listener, cancelListener);
new XPopup.Builder(context)
.setPopupCallback(new SimpleCallback())
.isCenterHorizontal(true)
.asCustom(confirmDialog)
.show();
}
public static void showConfirmDialog(Context context, String title, CharSequence content,
boolean isHideCancel, OnConfirmListener listener) {
ConfirmDialog confirmDialog = new ConfirmDialog(context)
.setCancelText(context.getString(R.string.cancel))
.setConfirmText(context.getString(R.string.text_sure))
.setTitleContent(title, content, null)
.setListener(listener, null);
if (isHideCancel) confirmDialog.hideCancelBtn();
new XPopup.Builder(context)
.setPopupCallback(new SimpleCallback())
.isCenterHorizontal(true)
.asCustom(confirmDialog)
.show();
}
public static void showConfirmDialog2(Context context, String title, CharSequence content, OnConfirmListener listener) {
ConfirmDialog confirmDialog = new ConfirmDialog(context)
.setCancelText(context.getString(R.string.cancel))
.setConfirmText(context.getString(R.string.close_dialog))
.setTitleContent(title, content, null)
.setListener(listener, null);
confirmDialog.hideCancelBtn();
new XPopup.Builder(context)
.setPopupCallback(new SimpleCallback())
.isCenterHorizontal(true)
.asCustom(confirmDialog)
.show();
}
public static void showConfirmDialog(Context context, String title, CharSequence content,
OnConfirmListener listener, OnCancelListener cancelListener) {
ConfirmDialog confirmDialog = new ConfirmDialog(context)
.setCancelText(context.getString(R.string.cancel))
.setConfirmText(context.getString(R.string.text_sure))
.setTitleContent(title, content, null)
.setListener(listener, cancelListener);
new XPopup.Builder(context)
.setPopupCallback(new SimpleCallback())
.isCenterHorizontal(true)
.asCustom(confirmDialog)
.show();
}
public static BasePopupView showConfirmDialog(Context context, String title, CharSequence content, OnConfirmListener listener) {
ConfirmDialog confirmDialog = new ConfirmDialog(context)
.setCancelText(context.getString(R.string.cancel))
.setConfirmText(context.getString(R.string.text_sure))
.setTitleContent(title, content, null)
.setListener(listener, null);
return new XPopup.Builder(context)
.dismissOnTouchOutside(false)
.dismissOnBackPressed(false)
.setPopupCallback(new SimpleCallback())
.asCustom(confirmDialog)
.show();
}
public static void showOptionPicker(Context context, String title, List<String> list, OnOptionsSelectListener listener) {
OptionsPickerView<String> pvOptions = new OptionsPickerBuilder(context, listener)
.setTitleText(title)
.setTitleSize(14)
.setSubCalSize(14)
.setContentTextSize(16)//设置滚轮文字大小
.setDividerColor(Color.LTGRAY)//设置分割线的颜色
// .setSelectOptions(0, 1)//默认选中项
.setBgColor(Color.WHITE)
.setTitleBgColor(Color.WHITE)
.setTitleColor(Color.BLACK)
.setSubmitColor(Color.rgb(255, 117, 105))
.setCancelColor(Color.rgb(153, 153, 153))
.setTextColorCenter(Color.BLACK)
.setCyclic(false, false, false)
.isRestoreItem(false)//切换时是否还原,设置默认选中第一项。
.isCenterLabel(true) //是否只显示中间选中项的label文字,false则每项item全部都带有label。
// .setBackgroundId(0x00000000) //设置外部遮罩颜色
.build();
pvOptions.setPicker(list);//一级选择器
pvOptions.show();
}
public static void showOptionPicker(Context context, String title, List<String> list, int option1, OnOptionsSelectListener listener) {
OptionsPickerView<String> pvOptions = new OptionsPickerBuilder(context, listener)
.setTitleText(title)
.setTitleSize(14)
.setSubCalSize(12)
.setContentTextSize(14)//设置滚轮文字大小
.setDividerColor(Color.LTGRAY)//设置分割线的颜色
.setSelectOptions(option1)//默认选中项
.setBgColor(Color.WHITE)
.setTitleBgColor(Color.WHITE)
.setTitleColor(Color.BLACK)
.setSubmitColor(Color.rgb(255, 117, 105))
.setCancelColor(Color.rgb(153, 153, 153))
.setTextColorCenter(Color.BLACK)
.setCyclic(false, false, false)
.isRestoreItem(false)//切换时是否还原,设置默认选中第一项。
.isCenterLabel(true) //是否只显示中间选中项的label文字,false则每项item全部都带有label。
// .setBackgroundId(0x00000000) //设置外部遮罩颜色
.build();
pvOptions.setPicker(list);//一级选择器
pvOptions.show();
}
/**
* Dialog 模式下,在底部弹出
*
* @param context
* @param title
* @param listener
*/
public static void showTimePicker(Context context, String title, OnTimeSelectListener listener) {
//系统当前时间
Calendar selectedDate = Calendar.getInstance();
Calendar startDate = Calendar.getInstance();
startDate.set(2000, 0, 1);
Calendar endDate = Calendar.getInstance();
TimePickerView mTimePickerView;
mTimePickerView = new TimePickerBuilder(context, listener)
.setDate(selectedDate)
.setRangDate(startDate, endDate)
.setTitleText(title)
.setTitleSize(14)
.setSubCalSize(12)
.setContentTextSize(14)
.setDividerColor(Color.LTGRAY)//设置分割线的颜色
.setBgColor(Color.WHITE)
.setTitleBgColor(Color.WHITE)
.setTitleColor(Color.rgb(51, 51, 51))
.setSubmitColor(Color.rgb(255, 117, 105))
.setCancelColor(Color.rgb(153, 153, 153))
.setTextColorCenter(Color.rgb(51, 51, 51))
.setType(new boolean[]{true, true, true, false, false, false})
.isCyclic(false)
.isDialog(true)
.build();
Dialog mDialog = mTimePickerView.getDialog();
if (mDialog != null) {
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM);
params.leftMargin = 0;
params.rightMargin = 0;
mTimePickerView.getDialogContainerLayout().setLayoutParams(params);
Window dialogWindow = mDialog.getWindow();
if (dialogWindow != null) {
dialogWindow.setWindowAnimations(R.style.picker_view_slide_anim);//修改动画样式
dialogWindow.setGravity(Gravity.BOTTOM);//改成Bottom,底部显示
}
}
mTimePickerView.show();
}
public static void showPasswordDialog(Context mContext, String title, String content, String inputContent, String hint, OnInputConfirmListener listener) {
new XPopup.Builder(mContext)
//.dismissOnBackPressed(false)
.autoOpenSoftInput(true)
// .autoFocusEditText(false) //是否让弹窗内的EditText自动获取焦点,默认是true
.isRequestFocus(false)
.isCenterHorizontal(true)
//.moveUpToKeyboard(false) //是否移动到软键盘上面,默认为true
.asInputConfirm(title, content, inputContent, hint, listener)
.bindLayout(R.layout.dialog_password_confirm)
.show();
}
}
使用:
showConfirmDialog("系统提示", "确定退出吗?", this::finish);
showConfirmDialog("系统提示", "确定退出吗?", ()->{});
List<String> productName = new ArrayList<>();
DialogHelper.showOptionPicker(mActivity, "列表选择", productName, new OnOptionsSelectListener() {
@Override
public void onOptionsSelect(int options1, int options2, int options3, View v) {
}
});
以上就是直播电商平台开发,底部弹窗,密码输入框,底部列表选择等, 更多内容欢迎关注之后的文章
标签:false,title,Color,listener,输入框,底部,context,new,电商 来源: https://www.cnblogs.com/yunbaomengnan/p/16612666.html