-  - The Android Arsenal – Toasts -  - The Android Arsenal – Toasts -  - The Android Arsenal – Toasts

Toaster is library that helps in showing toast and dialog.

  • Add the dependency from jCenter to your app’s (not project) build.gradle file:
repositories {
    jcenter()
}

dependencies {
    compile 'net.alexandroid.utils:toaster:1.2'
}

-  - The Android Arsenal – Toasts

 Toaster.showToast(this, "This is our awesome toast");
 // 300 - animation duration, 00 - visible duration
 Toaster.showToast(this, "This is our awesome toast", 300, 500);  

-  - The Android Arsenal – Toasts

private Toaster mToaster;
...
private void showDialog() {
    mToaster = new Toaster.Builder(this)
            .setTitle("Dialog title")
            .setText("Text of the dialog here")
            .setPositive("OK")
            .setNegative("CANCEL")
            .setAnimationDuration(300)
            .setCallBack(this).build();
    mToaster.show();
}  

@Override
public void onBackPressed() {
   if (mToaster == null || mToaster.onBackPressed()) {
       super.onBackPressed();
    }
}
  • Custom layout for dialog:

-  - The Android Arsenal – Toasts

 mToaster = new Toaster.Builder(this)
.setCustomLayout(R.layout.custom)
...

https://github.com/Pulimet/Toaster-Library/blob/master/app/src/main/res/layout/custom.xml

Copyright 2018 Alexey Korolev

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, 
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here