ben LayoutInflater
amacını anlamıyorum çünküandroid özel tost
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();
Ancak bu kodu kullanarak özel tost yapmak başardı, bu kod ... modifiye
Toast toast = new Toast(getApplicationContext());
toast.setView(findViewById(R.id.custom_toast));
toast.setDuration(Toast.LENGTH_SHORT);
toast.show();
Ve RuntimeException "setview denilen olmalı" diyerek olsun ..
Neden yapamıyorum
LayoutInflater
kullanmadan görünümü tost atayın mı?Bu deneyimi diğer özel görünümler için uygulayabilmem için genel olarak
LayoutInflater
'un amacı nedir?
Düzenleme: Ben onListItemClick()
arabirim yönteminde .. içeriği ayarlandıktan sonra bu kodları kullanıyorum ..
ben "içten do LayoutInflater ne" iyi bir soru olacağını düşünüyorum ederiz? – Behnam