|
@@ -42,22 +42,22 @@ public class ToastUtil {
|
|
* 创建自定义Toasts :
|
|
* 创建自定义Toasts :
|
|
*/
|
|
*/
|
|
public void showShort(String toastStr) {
|
|
public void showShort(String toastStr) {
|
|
- int dp26 = SizeUtils.dp2px(26);
|
|
|
|
- int dp10 = SizeUtils.dp2px(10);
|
|
|
|
- TextView mContentView = new TextView(Utils.getApp());
|
|
|
|
- mContentView.setGravity(Gravity.CENTER);
|
|
|
|
- mContentView.setBackgroundResource(R.drawable.shape_toast);
|
|
|
|
- mContentView.setTextSize(15);
|
|
|
|
- mContentView.setTextColor(Utils.getApp().getResources().getColor(R.color.white));
|
|
|
|
- mContentView.setPadding(dp26, dp10, dp26, dp10);
|
|
|
|
- mContentView.setText(toastStr);
|
|
|
|
- ToastUtils.getDefaultMaker().setGravity(Gravity.CENTER, 0, 0).show(mContentView);
|
|
|
|
-// if (init(toastStr, Toast.LENGTH_SHORT) == null) {
|
|
|
|
-// toast = new Toast(Utils.getApp());
|
|
|
|
-// toast.setText(toastStr);
|
|
|
|
-// toast.setDuration(Toast.LENGTH_SHORT);
|
|
|
|
-// toast.show();
|
|
|
|
-// }
|
|
|
|
|
|
+// int dp26 = SizeUtils.dp2px(26);
|
|
|
|
+// int dp10 = SizeUtils.dp2px(10);
|
|
|
|
+// TextView mContentView = new TextView(Utils.getApp());
|
|
|
|
+// mContentView.setGravity(Gravity.CENTER);
|
|
|
|
+// mContentView.setBackgroundResource(R.drawable.shape_toast);
|
|
|
|
+// mContentView.setTextSize(15);
|
|
|
|
+// mContentView.setTextColor(Utils.getApp().getResources().getColor(R.color.white));
|
|
|
|
+// mContentView.setPadding(dp26, dp10, dp26, dp10);
|
|
|
|
+// mContentView.setText(toastStr);
|
|
|
|
+// ToastUtils.getDefaultMaker().setGravity(Gravity.CENTER, 0, 0).show(mContentView);
|
|
|
|
+ if (init(toastStr, Toast.LENGTH_SHORT) == null) {
|
|
|
|
+ toast = new Toast(Utils.getApp());
|
|
|
|
+ toast.setText(toastStr);
|
|
|
|
+ toast.setDuration(Toast.LENGTH_SHORT);
|
|
|
|
+ toast.show();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private Toast init(String message, int duration) {
|
|
private Toast init(String message, int duration) {
|