Android-封装Toast
来源:互联网 发布:mac终端颜色配置 编辑:程序博客网 时间:2024/05/29 18:53
public class CustomToast {
/**
* Method to display toast message.
*
* @param activity
* the activity context
* @param stringResId
* the string resource id
*/
public static void showToast(final Activity activity, final int stringResId) {
try {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Toast toast = Toast.makeText(activity, stringResId,
Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
} catch (Exception e) {
VCLog.error(
Category.CAT_GUI,
"CustomToast: showToast: run: Exception->"
+ e.getMessage());
e.printStackTrace();
}
}
});
} catch (Exception e) {
VCLog.error(Category.CAT_GUI, "CustomToast: showToast: Exception->"
+ e.getMessage());
e.printStackTrace();
}
}
/**
* Method to display toast message.
*
* @param activity
* the activity context
* @param message
* the message string
*/
public static void showToast(final Activity activity, final String message) {
try {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Toast.makeText(activity, message, Toast.LENGTH_LONG)
.show();
} catch (Exception e) {
VCLog.error(Category.CAT_GUI,
"CustomToast: showToast (message): run: Exception->"
+ e.getMessage());
e.printStackTrace();
}
}
});
} catch (Exception e) {
VCLog.error(
Category.CAT_GUI,
"CustomToast: showToast (message): Exception->"
+ e.getMessage());
e.printStackTrace();
}
}
}
/**
* Method to display toast message.
*
* @param activity
* the activity context
* @param stringResId
* the string resource id
*/
public static void showToast(final Activity activity, final int stringResId) {
try {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Toast toast = Toast.makeText(activity, stringResId,
Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
} catch (Exception e) {
VCLog.error(
Category.CAT_GUI,
"CustomToast: showToast: run: Exception->"
+ e.getMessage());
e.printStackTrace();
}
}
});
} catch (Exception e) {
VCLog.error(Category.CAT_GUI, "CustomToast: showToast: Exception->"
+ e.getMessage());
e.printStackTrace();
}
}
/**
* Method to display toast message.
*
* @param activity
* the activity context
* @param message
* the message string
*/
public static void showToast(final Activity activity, final String message) {
try {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Toast.makeText(activity, message, Toast.LENGTH_LONG)
.show();
} catch (Exception e) {
VCLog.error(Category.CAT_GUI,
"CustomToast: showToast (message): run: Exception->"
+ e.getMessage());
e.printStackTrace();
}
}
});
} catch (Exception e) {
VCLog.error(
Category.CAT_GUI,
"CustomToast: showToast (message): Exception->"
+ e.getMessage());
e.printStackTrace();
}
}
}
阅读全文
0 0
- Android Toast 简单封装
- Android Toast 简单封装
- Android Toast提示封装
- Android Toast 简单封装
- Android封装吐司Toast
- Android 封装Toast
- Android-封装Toast
- Android--Toast的简单封装
- Android封装Toast工具类
- Android Toast 封装,避免Toast消息覆盖,替换系统Toast最好用的封装
- 输出控制:Android Log\Toast封装
- Toast 封装
- 《老罗Android第二季》布局、Dialog与Toast封装
- Toast的封装
- Toast封装使用
- react native Toast封装
- Toast封装,避免多次toast提示
- android Toast
- git的使用教程 简略版
- 高级程序员应该掌握哪些编程技术
- jackson出现错误 Unrecognized field,JsonIgnoreProperties忽略不起作用
- 西门子s7-200PLC的定时器
- 勒索病毒还未收场 内幕已经足够惊人
- Android-封装Toast
- 【iOS10 SpeechRecognition】语音识别 现说现译的最佳实践
- MIPI屏对RF的影响
- ant 打包 hadoop2.7.0 eclipse插件中的问题
- Linux下加快SSH链接验证
- 九大排序之——快速排序
- C++之简单哈希表查找法的实现和循环查找法的比较
- 通过添加hint加速insert操作
- python设置国内源