MotionToast icon indicating copy to clipboard operation
MotionToast copied to clipboard

Java Implementation Examples

Open m-anshuman2166 opened this issue 3 years ago • 2 comments

Java Implementation Examples are needed.......... Many devs prefer Java

m-anshuman2166 avatar Nov 15 '21 12:11 m-anshuman2166

I hope this example will help you guys. Let's assume you want to see the toast upon clicking a button, the code will be:

startBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MotionToast.Companion.createColorToast(
                        MainActivity.this,
                        "Welcome",
                        "Enjoy the application",
                        MotionToastStyle.INFO,
                        MotionToast.GRAVITY_BOTTOM,
                        MotionToast.LONG_DURATION,
                        ResourcesCompat.getFont(MainActivity.this, R.font.helvetica_regular)
                );
            }
});

You may change the motion toast style to your preferences :)

prasmaran avatar Jan 14 '22 17:01 prasmaran

And don't forget to include the maven { url "https://jitpack.io" } like below in the settings.gradle

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        **maven { url "https://jitpack.io" }**
        jcenter() // Warning: this repository is going to shut down soon
    }
}
rootProject.name = "your_app_name"
include ':app'

prasmaran avatar Jan 14 '22 17:01 prasmaran