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!
Asked
Active
Viewed 972 times
1 Answers
2
You need to call
Toast.makeText(context, "Hi there!", Toast.LENGTH_LONG).show();
in widget's onClick()
method of View.OnClickListener

Community
- 1
- 1

Ambrish Pathak
- 3,813
- 2
- 15
- 30
-
For widget it extends from Appwidgetprovider!, Does the findviewbyId work in widget class?? I tried XML attribute android:onClick also, but couldn't make it work,, where as the toast is working fine in onUpdate, onEnabled and onDisabled methods – Manjunath Prabhakar Feb 11 '17 at 18:17
-
I did refer! I'm positive for invoking an activity on image button press! But I need a toast! I invoke a toast on a image button click! – Manjunath Prabhakar Feb 11 '17 at 18:26