사용자 정의 Toast, 프로그램 종료 시 Toast도 종료, Toast의 사용

1242 단어 androidlayoutnull
한 응용 프로그램에서 Toaster를 힌트로 사용할 때 이러한 문제를 발견했다. 어떤 조건이 맞으면 Toaster 대화상자가 뜨고 이 조건을 끊임없이 실행하며 Toaster를 계속 진행한다.show의 표시는 몇 번을 실행하면 몇 번을 보여 줍니다. 이 프로그램이 종료되더라도 끊임없이 Toast를 표시합니다.show에 따르면, 이렇게 하면 사용자에게 좋지 않은 체험을 가져다 줄 수 있다.우리가 프로그램을 종료하면 Toast가 되지 않습니다.show 가 표시됩니다.
프로그램이 onDestroy () 를 종료할 때 Toaster를 진행할 수 있습니다.cancel().실현될 수 있지만 Toaster는 반드시 전역적이고 같은 Toaster이어야 한다
      
 mToast = new Toast(this);    //OnCreate ()
    
     LayoutInflater inflater = LayoutInflater.from(this);
     View view2 = inflater.inflate(R.layout.toas, null);
     mToast.setView(view2);
     mToast.setDuration(1000);

    LayoutInflater, LayoutInflater  :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical" android:layout_width="wrap_content"
	android:layout_height="wrap_content">
	<TextView android:layout_width="wrap_content"
		 android:background="#ff000000"
		android:layout_height="wrap_content" android:text="@string/most_char" />

</LinearLayout>

 
위에서 설명한 대로 Toaster에 대한show의 제어.

좋은 웹페이지 즐겨찾기