Simple ToastUtil for Android.
You can download a jar from GitHub's releases page.
Or use Gradle:
compile 'tech.gujin:toast-util:1.1.1'
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.
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.