Skip to content

Latest commit

History

History
78 lines (64 loc) 路 2.27 KB

README.md

File metadata and controls

78 lines (64 loc) 路 2.27 KB

ToastUtil

API Download Build Status

Simple ToastUtil for Android.

涓枃浠嬬粛

Download

You can download a jar from GitHub's releases page.

Or use Gradle:

implementation 'tech.gujin:toast-util:1.2.0'

How to use

Initialize in your application class

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        ToastUtil.initialize(this);
        // replaceable mode
        // ToastUtil.initialize(this, ToastUtil.Mode.REPLACEABLE);
    }
}

Register application class in AndroidManifest.xml

<application
    android:name="yourPackageName.MyApplication"
    ...
</application>      

Use

ToastUtil.show("ToastUtil");

Or in sub-thread

ToastUtil.postShow("ToastUtil");

There are two modes in the util , introduce them through a gif.

  • ToastUtil.Mode.NORMAL
  • ToastUtil.Mode.REPLACEABLE

For more information please see the sample model and javadocs.

License

Copyright GuJin

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, software
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.