简体   繁体   中英

How to create widget in android with button, edittext and more components

I want to create widget in android with a button, edittext, spinner or more components. Help me please!!!

You have to design the layout of you widget, is a normal layout file, but not all the view are allowed here.

Now you have to extend AppWidgetProvider and create your class, here you can override the methods triggered when the app widget is updated, deleted, enabled and others.

In the onUpdate() you can create a RemoteViews to set the layout you had created before.

Now is the time for appwidget-provider, an XML file that.

The last thing is to add widget to the manifest, within the application tags, you have to add receiver tag and the define intent filter and metadata.

I left to you the documentation https://developer.android.com/guide/topics/appwidgets/index.html and a little tutorial for a very simple widget: http://www.androidauthority.com/create-simple-android-widget-608975/

Hope this helps you.

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