0
我想在佈局頂部顯示自定義烤麪包信息,例如 - 當出現「無互聯網連接」時。對於那件事我正在使用AppMsg library from here.在佈局上顯示自定義烤麪包,例如AppMsg
但是這個圖書館有幾個問題,像它不斷顯示消息。我需要相同類型的實現。
任何人都請建議?
我想在佈局頂部顯示自定義烤麪包信息,例如 - 當出現「無互聯網連接」時。對於那件事我正在使用AppMsg library from here.在佈局上顯示自定義烤麪包,例如AppMsg
但是這個圖書館有幾個問題,像它不斷顯示消息。我需要相同類型的實現。
任何人都請建議?
您可以自定義Toastview這樣,
LayoutInflater inflater = getLayoutInflater();
View toastLayout = inflater.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.custom_toast_layout));
Toast toast = new Toast(getApplicationContext());
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(toastLayout);
toast.show();
custom_toast佈局,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Custom Android Toast View Example" />
<Button
android:id="@+id/show_custom_toast"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:text="Show Custom Toast" />
</RelativeLayout>
我需要一個像AppMsg類的實現。我不想添加我自己的習慣。對不起,謝謝你的回答 –