1.写入xml布局代码:
2.封装方法,代码如下:
public static void showDialogThrough(Activity activity,String msg){
Toast toast = new Toast(activity);
View inflate = LinearLayout.inflate(activity, R.layout.new_dialog_hint, null);
inflate.findViewById(R.id.dialog_hint_iv).setBackgroundResource(R.drawable.through_logo);
TextView textView = inflate.findViewById(R.id.dialog_hint_tv);
textView.setText(msg);
toast.setView(inflate);
toast.setGravity(Gravity.CENTER|Gravity.TOP,0,0);
toast.show();
}
3.调用方法:
AllDialogUtils.showDialogThrough(SettingActivity.this,"设置成功");
4.总结:
(1)该方法需要传入Activity,你可以使用getActivity方法获取上下文。这样在调用方法时就只输入字符串内容即可。
(2)很高兴与大家分享知识,欢迎大家指点。



