public void dispalyToast(SHSact_Main sHSact_Main,String message){
LayoutInflater inflater = sHSact_Main.getLayoutInflater();
View layout = inflater.inflate(R.layout.custome_toast,
(ViewGroup) sHSact_Main.findViewById(R.id.custom_toast_lin_main));
TextView txt_heading= (TextView) layout.findViewById(R.id.custom_toast_txt_heading);
txt_heading.setText(message);
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
}
// Create XML file Name was "custome_toast"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_toast_lin_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/toast_bg"
android:padding="@dimen/toast_padding_txtheading">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/toast_padding_txtheading">
<TextView
android:id="@+id/custom_toast_txt_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/toast_text_heading"
android:textSize="@dimen/toast_textsize_heading"/>
</LinearLayout>
</LinearLayout>
No comments:
Post a Comment