A leading digital platform to offer engaging shopping experience to users
A mobile app to digitalise & expand KFC’s digital footprint
The MIT Innovation award-winning app withh $52 million funding reshaping the employment lanscape.
A transforming ERP solution for the world’s largest furniture retailer
A refined UX strategy for Domino's to increase their conversion rate by 23%
A SaaS-based financial literacy and smart money management platform for kids
Hiring Fintech Software Developers – A Step-by-Step Process and Costs
How AI in Stock Trading will Transform Markets
How AI is Proving as a Game Changer in Manufacturing – Use Cases and Examples
How data mining helps in business intelligence
Why your enterprise business needs an IT strategy
What entrepreneurs need to know about Conversational AI
Healthcare App Development Guide – Use Cases, Costs, Trends & More
The Ultimate iOS App Development Guide for Business
The Definitive Guide to Flutter App Development
The Definitive Guide to Enterprise Digital Transformation
The Ultimate Guide to Software Development
Cloud Computing – An Ultimate Guide for Businesses
Appinventiv Wins Deloitte Fast 50 India 2023 Award
Clutch Names Appinventiv The Top Fintech App Development Agency
Appinventiv Ranked Top 2 in the List of Most Promising Mobile Application Solution Providers – 2018 by CIO Review
ShifaCare Wins ‘Top 50 Healthcare Companies’ Award at IFAH Dubai
Clutch Names Appinventiv a Top Mobile Development Agency for Startups
Appinventiv Named ‘The Top App Developer’ by Clutch
How to Estimate the Social Media App Development Cost Budget ?
79 Points Mobile App Development All-Inclusive Checklist
Why Investing in Artificial Intelligence is the Need of the Hour?
Things You Must Consider During Web Application Development
Apple’s Event on October 30, 2018: What to Expect this time?
Enterprise IMs – The New Mantra To Business Productivity
Toast is a transient notification that stays visible for a few seconds before fading out. It provides a simple feedback about an operation in a small popup without interrupting the application. We can use Toast for debugging purpose as well.
Toasts are excellent for informing our users of events without forcing them to open an Activity or browse a Notification. They provide a perfect mechanism for alerting users of events occurring in background services without interrupting the foreground applications. Generally, your application should show Toasts only if one of its Activities is active.
The Toast class consists of a static make Text method that makes a standard Toast display window.
1. Open “MainActivity.java” file and add following JAVA code.
File :src/package-name/MainActivity.java
MainActivity.javaJava
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class Main Activity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void SimpleToast(View view) {
// Call Toast to show msg
Toast.makeText(this, “Android Simple Toast”, Toast.LENGTH_LONG).show();
}
}
2. Open “res/layout/activity_main.xml” file and put this xml code it into file:
File : res/layout/activity_main.xml
activity_main.xml
XHTML
android:layout_width=”match_parent”
android:layout_height=”match_parent”
>
android:id=”@+id/tv_simple_toast”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginTop=”10dp”
android:padding=”5dp”
android:text=”Android Simple Toast Example” />
android:id=”@+id/btn_click”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_alignParentLeft=”true”
android:layout_alignParentRight=”true”
android:layout_below=”@+id/tv_simple_toast”
android:layout_marginTop=”41dp”
android:text=”Simple Toast Click”
android:onClick=”SimpleToast”/>
In Android Studio, create a new Toast, pass the current Context, the text message to show and also the length of your time to show (LENGTH_SHORT or LENGTH_LONG) into the make Text method. Once the Toast has been made, you’ll be able to show it by calling show.
Sometimes a simple text message is not enough, we have to use a customized layout for our toast notification. To make a custom layout, define a view layout, in XML or in your application code and pass the root view object to the set View (View) method.
1. Create “res/layout/mycustom_toast.xml” file and put this xml code it into a file:
File : res/layout/mycustom_toast.xmlCustom_layout
android:orientation=”vertical” android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:background=”#d4ffcd”
android:id=”@+id/custom”
>
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:background=”@drawable/sucess”
android:id=”@+id/iv_success” />
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”RECORD SUCESSFULLY SAVED”
android:id=”@+id/tv_record”
android:layout_marginTop=”5dp”
android:textSize=”20dp”
android:layout_gravity=”center_horizontal”
android:layout_alignParentTop=”true”
android:layout_alignParentRight=”true”
android:layout_alignParentEnd=”true”
android:layout_toRightOf=”@+id/iv_success”
android:layout_toEndOf=”@+id/iv_success” />
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”CUSTOM TOAST “
android:id=”@+id/tv_custom_toast”
android:textSize=”15dp”
android:layout_marginTop=”5dp”
android:layout_gravity=”center_horizontal”
android:layout_below=”@+id/tv_record”
android:layout_toRightOf=”@+id/iv_success”
android:layout_toEndOf=”@+id/iv_success” />
Custom Toast in java, that Layout of the Toast is “customtoast.xml” call by View.
My Custom Toast
R.id.btn_custom:
//get your custom_toast.xml layout
LayoutInflaterinflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.customtoast,null);
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
By now, you should be able to create a Taost.
Appinventiv Technologies is the most sought after iOS and Android app development company in India providing top grade mobile application development services across the globe. Appinventiv has been ranked No. 1 in Appfutura which is the most revered community for app developers. It has onboarded the best developers and designers who have a great expertise in the domain of app development.
B-25, Sector 58,
Noida- 201301,
Delhi - NCR, India
Suite 3810, Bankers Hall West,
888 - 3rd Street Sw
Calgary Alberta
1600+ transformation engineers delivered
3000+ game-changing products.
We chose Appinventiv to build our financial literacy and money management app from start to finish. From the first call, we were very impressed with Appinventiv’s professionalism, expertise, and commitment to delivering top-notch results.
It has been a pleasure working with Appinventiv. The team is not only extremely versatile and competent but also very professional, courteous, and responsive. We certainly plan to continue working with Appinventiv for an indefinite period.
We took a big leap of faith with Appinventiv who helped us translate our vision into reality with the perfectly comprehensive Edamama eCommerce solution. We are counting to get Edamama to launch on time and within budget, while rolling out the next phase of the platform with Appinventiv.
I just want to take a moment to thank the entire Appinventiv team for your incredible support. We truly appreciate everything you've done, and we're excited to continue working together as we grow here at KODA
After researching numerous companies, we finally found Appinventiv, and it was the best decision we could have made. They successfully addressed the challenges with our existing app and provided solutions that exceeded our expectations.
We approached Appinventiv with a clear vision to build a robust and future-ready platform that could seamlessly integrate with the busy lifestyle of our customers while uplifting their overall experience and giving us a competitive edge.
1600+ transformation engineers delivered
3000+ game-changing products.
Connect with our consultation experts to get:
Insights specific to your business needs
Roadmap to overcome your challenges
Opportunities to scale your business in this niche.