First on the request renderings
Code:
public class ToastUtil { public static void toast(String s){ Toast.makeText(context,s,Toast.LENGTH_SHORT).show(); } private static TextView mTextView; private static ImageView mImageView; public static void showToast(String message,int imag) { //加载Toast布局 View toastRoot = LayoutInflater.from(context).inflate(R.layout.toast, null); //初始化布局控件 mTextView = (TextView) toastRoot.findViewById(R.id.message); mImageView = (ImageView) toastRoot.findViewById(R.id.imageView); //为控件设置属性 mTextView.setText(message); if(imag==0){ mImageView.setVisibility(View.GONE); }else { mImageView.setImageResource(imag); } //Initialization of Toast Toast toastStart = new Toast(context); //Get screen height WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); int height = wm. getDefaultDisplay().getHeight(); //Toast's Y coordinate is 1/3 of the screen height, so there will be no misfit problems toastStart.setGravity(Gravity.TOP, 0, height / 4); toastStart.setDuration(Toast .LENGTH_SHORT); toastStart.setView(toastRoot); toastStart.show(); } }
use:
if(objectBaseArrayBean.getCode().equals("200")){ v.updateLastEquipmentSuccess(); ToastUtil.showToast(objectBaseArrayBean.getMessage(),R.mipmap.success_icon); }else { ToastUtil.showToast(objectBaseArrayBean.getMessage(),R.mipmap.error_icon); }
Personal notes. The comments are not detailed.