은 내가 LayoutInflater
의 목적을 이해하지 않기 때문에,안드로이드 사용자 정의 토스트
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.custom_toast_layout, (ViewGroup)findViewById(R.id.custom_toast));
TextView text = (TextView) layout.findViewById(R.id.toast_tv);
text.setText("Hello! This is a custom toast!");
Toast toast = new Toast(getApplicationContext());
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
그러나이 코드를 사용하여 사용자 정의 토스트를 만들 수 있었다, 나는이에 코드를 ... 수정
Toast toast = new Toast(getApplicationContext());
toast.setView(findViewById(R.id.custom_toast));
toast.setDuration(Toast.LENGTH_SHORT);
toast.show();
내가 RuntimeException의는 "setView가 호출되어 있어야합니다"라고 말하는 ..
왜 그냥 할 수 없습니다
LayoutInflater
을 사용하지 않고보기를 토스트에 지정 하시겠습니까?이 경험을 다른 사용자 지정보기에 적용 할 수 있도록 일반적으로
LayoutInflater
의 목적은 무엇입니까?
편집 : 내가 onListItemClick()
인터페이스 방법 .. 내용이 설정된 후 이러한 코드를 사용하고 있습니다 ..
"내부적으로 LayoutInflater는 무엇을할까요?" – Behnam