简体   繁体   中英

How to display a toast on image button click in android widget

I'm creating a widget that had a button! When I click on a button. It just reads my location and toasts it! It should not open any activity! Just a toast on the button click in the widget! Need help!

You need to call

Toast.makeText(context, "Hi there!", Toast.LENGTH_LONG).show();

in widget's onClick() method of View.OnClickListener

If using AppWidgetProvider take a look at this and this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM