Prevent crash

pull/162/head
M66B 5 years ago
parent 58b41f33aa
commit 20b47840cc

@ -21,7 +21,10 @@ public class ToastEx extends Toast {
ToastEx toast = new ToastEx(context);
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.toast, null);
view.setBackground(context.getResources().getDrawable(R.drawable.toast_background, context.getTheme()));
TextView tv = view.findViewById(android.R.id.message);
tv.setTextColor(Helper.resolveColor(context, R.attr.colorToastForeground));
tv.setText(text);
toast.setView(view);
toast.setDuration(duration);

@ -2,7 +2,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/toast_background"
android:orientation="vertical"
android:paddingStart="12dp"
android:paddingTop="6dp"
@ -15,6 +14,5 @@
android:layout_height="wrap_content"
android:gravity="center"
android:text="Message"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorToastForeground" />
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
</LinearLayout>
Loading…
Cancel
Save