Utills 클래스 메서드를 호출하여 사용자 정의 Toast 메시지를 화면에 표시 할 수있게하려고합니다.Utills 클래스의 사용자 토스트
내 코드 : 나는
(ViewGroup) findViewById(R.id.custom_toast_layout)
난 상태 컴파일 오류가 전화 라인 4와 proble이
static public void ShowToast(Context context,String message, int duration)
{
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// Inflate the Layout
View layout = inflater.inflate(R.layout.custom_toast,(ViewGroup) findViewById(R.id.custom_toast_layout));
TextView text = (TextView) layout.findViewById(R.id.textToShow);
// Set the Text to show in TextView
text.setText(message);
Toast toast = new Toast(context);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(duration);
toast.setView(layout);
toast.show();
}
:
방법 findViewById를을 (INT)은 SystemUtills 유형에 대해 정의되지 않았습니다.
어떻게 해결할 수 있습니까?
감사합니다.
참고 http://developer.android.com/guide/topics/ui/notifiers/toasts.html#CustomToastView%20. –