Ä¿½ºÅÒ Å佺Ʈ ¶ç¿ì±â(To show Custom Toast) |
|
|
 |
8³â Àü |
Ä¿½ºÅÒ Å佺Ʈ ¶ç¿ì±â
public void showCustomToast(String msg, int duration){
//Retrieve the layout inflator
LayoutInflater inflater = getLayoutInflater();
//Assign the custom layout to view
//Parameter 1 - Custom layout XML
//Parameter 2 - Custom layout ID present in linearlayout tag of XML
View layout = inflater.inflate(R.layout.result_toast,
(ViewGroup) findViewById(R.id.toast_layout_root));
TextView msgView = (TextView)layout.findViewById(R.id.toastMessage);
msgView.setText(msg);
//Return the application context
Toast toast = new Toast(getApplicationContext());
//Set toast gravity to bottom
toast.setGravity(Gravity.BOTTOM, 0, 0);
//Set toast duration
toast.setDuration(duration);
//Set the custom layout to Toast
toast.setView(layout);
//Display toast
toast.show();
}
|
|
̵̧ : 327 |
̵̧
¸ñ·Ï
|
|