@@ -0,0 +1,2256 @@
+package com.example.liujianglong.testapp;%0D%0A%0D%0Aimport android.content.Context;%0D%0Aimport android.view.View;%0D%0Aimport android.widget.ImageView;%0D%0Aimport android.widget.LinearLayout;%0D%0Aimport android.widget.TextView;%0D%0Aimport android.widget.Toast;%0D%0A%0D%0A/**%0D%0A * Created by liujianglong on 2017/9/11.%0D%0A */%0D%0A%0D%0Apublic class ToastUtil %7B%0D%0A    private static Toast mToast;%0D%0A    private static int mGravity = -1;%0D%0A%0D%0A    private ToastUtil() %7B%0D%0A        /*prevent form initial*/%0D%0A    %7D%0D%0A%0D%0A    public static void configGravity(int gravity) %7B%0D%0A        mGravity = gravity;%0D%0A    %7D%0D%0A%0D%0A    private static LinearLayout getView(Context context) %7B%0D%0A        Context appContext = context.getApplicationContext();%0D%0A        LinearLayout layout = new LinearLayout(appContext);%0D%0A        TextView textView = new TextView(appContext);%0D%0A        ImageView imageView = new ImageView(appContext);%0D%0A        layout.addView(imageView);%0D%0A        layout.addView(textView);%0D%0A        return layout;%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * set text ,duration and drawable%0D%0A     */%0D%0A    public static void showToastWithDrawable(Context context, String text, int drawableId, int duration) %7B%0D%0A        LinearLayout toastView = getView(context);%0D%0A        TextView textViewCenter = (TextView) toastView.getChildAt(1);%0D%0A        textViewCenter.setText(text);%0D%0A        if (drawableId %3E 0) %7B%0D%0A            ImageView image = (ImageView) toastView.getChildAt(0);%0D%0A            image.setBackgroundResource(drawableId);%0D%0A            image.setVisibility(View.VISIBLE);%0D%0A        %7D%0D%0A        if (mToast != null) %7B%0D%0A            mToast.cancel();%0D%0A        %7D%0D%0A        mToast = new Toast(context.getApplicationContext());%0D%0A%0D%0A        if (mGravity %3E= 0) %7B%0D%0A            mToast.setGravity(mGravity, 0, 0);%0D%0A        %7D%0D%0A        mToast.setDuration(duration);%0D%0A        mToast.setView(toastView);%0D%0A        mToast.show();%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * set text, default LENGTH_SHORT time%0D%0A     */%0D%0A    public static void showToast(Context context, String text) %7B%0D%0A        showToastWithDrawable(context, text, -1, Toast.LENGTH_SHORT);%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * set string resource ID, default LENGTH_SHORT time%0D%0A     */%0D%0A    public static void showToast(Context context, int stringResId) %7B%0D%0A        showToast(context, context.getString(stringResId));%0D%0A    %7D%0D%0A%7D%0D%0A

add toastUtil