1.多字符串toast,一般用于开发时查知方法运行
2.非主线程中toast
import android.content.Context;
import android.os.Handler;
import android.widget.Toast;
/**
* Created by wangxingsheng on 16/8/10.
*/
public class ToastUtil {
public static void talk(Context context, String... args){
StringBuilder sb = new StringBuilder();
String temp = "";
for (Object obj : args){
if(obj!=null){
temp = obj.toString();
}else{
temp = " *null* ";
}
sb.append(temp);
}
Toast.makeText(context,sb.toString(),Toast.LENGTH_SHORT).show();
}
public static void talkInThread(final Context context, final String... args){
Handler handler = new Handler(context.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
talk(context,args);
}
});
}
}