Android开发中,吐司是个很重要的交互工具,下面就将我在项目中的吐司封装工具类分享一下:
/**
* Created by Michael on 2018/8/23.
*/
public class ToastUtil {
public static void netUnlinked(Context context){
if (context != null){
Toast.makeText(context,
BuildConfig.NETWORK_UNLINKED,
Toast.LENGTH_SHORT)
.show();
}
}
public static void accessServerFailed(Context context){
if (context != null){
Toast.makeText(context,
BuildConfig.ACCESS_SERVER_FAILED,
Toast.LENGTH_SHORT)
.show();
}
}
public static void connectTimeout(Context context){
if (context != null){
Toast.makeText(context,
BuildConfig.CONNECTION_TIMEOUT,
Toast.LENGTH_SHORT)
.show();
}
}
public static void toast(Context context,String str){
if (context != null && str != null){
Toast.makeText(context,
str,
Toast.LENGTH_SHORT)
.show();
}
}
}

142

被折叠的 条评论
为什么被折叠?



