Questions tagged [android-widget]

Either relates to Home Screen widgets, or to general UI elements used on an Android Application screen.

From Android Documentation

Widgets are an essential aspect of home screen customization. You can imagine them as "at-a-glance" views of an app's most important data and functionality that is accessible right from the user's home screen. Users can move widgets across their home screen panels, and, if supported, resize them to tailor the amount of information within a widget to their preference.

Common elements are :

  • AbsoluteLayout
  • AnalogClock
  • AutoCompleteTextView
  • Button
  • CalendarView
  • CheckBox
  • CheckedTextView
  • Chronometer
  • CompoundButton
  • DatePicker
  • DigitalClock
  • EditText
  • ExpandableListView
  • FrameLayout
  • Gallery
  • GridView
  • HorizontalScrollView
  • ImageButton
  • ImageSwitcher
  • ImageView
  • LinearLayout
  • ListView
  • MediaController
  • NumberPicker
  • ProgressBar
  • QuickContactBadge
  • RadioButton
  • RadioGroup
  • RatingBar
  • RelativeLayout
  • ScrollView
  • SearchView
  • SeekBar
  • SlidingDrawer
  • Spinner
  • StackView
  • TabHost
  • TableLayout
  • TableRow
  • TabWidget
  • TextSwitcher
  • TextView
  • TimePicker
  • Toast
  • ToggleButton
  • VideoView
  • ViewAnimator
  • ViewFlipper
  • ViewSwitcher
  • ZoomButton
  • ZoomControls
5711 questions
134
votes
16 answers

Using setImageDrawable dynamically to set image in an ImageView

I am generating a string from database dynamically which has the same name of image in drawable folder. Now I want to set that value for ImageView using setImageDrawable(R.id.StringGenerated) dynamically. Any Suggestions..
Arun
  • 1,407
  • 2
  • 10
  • 10
131
votes
3 answers

How to force ViewPager to re-instantiate its items

I am using ViewPager to allow user to swipe between its views. Is there a way how to force this ViewPager to reload/re-instantiate its views in case that they are no longer valid or needs to be refreshed? I tried to call notifyDataSetChanged() on…
gordonfreeman
  • 2,485
  • 2
  • 16
  • 13
124
votes
6 answers

Assign width to half available screen width declaratively

Is it possible to assign a widget width to half the available screen width, and do it using declarative xml?
bugzy
  • 7,086
  • 9
  • 42
  • 44
118
votes
8 answers

How did Google manage to do this? Slide ActionBar in Android application

I really want to implement this (the side navigation) in an app of my own, does anyone know how Google managed to do this? They seem to have pulled the current window aside and put in a fly-in navigation of their own.
109
votes
10 answers

Programmatically update widget from activity/service/receiver

I know it's possible, but I can't figure out a way to trigger an update of my widget from the main activity. Isn't there some general intent I can broadcast?
Nuvious
  • 1,469
  • 2
  • 12
  • 21
103
votes
6 answers

how to validate a URL / website name in EditText in Android?

I want to take input, a URL or just a website name like, www.google.com from EditText in Android and on user click on the Button to submit or when the EditText looses the focus the URL should be validated, like it is in the format…
Preetam
  • 5,528
  • 10
  • 32
  • 39
100
votes
7 answers

Android: Cloning a drawable in order to make a StateListDrawable with filters

I'm trying to make a general framework function that makes any Drawable become highlighted when pressed/focused/selected/etc. My function takes a Drawable and returns a StateListDrawable, where the default state is the Drawable itself, and the state…
talkol
  • 12,564
  • 11
  • 54
  • 64
96
votes
11 answers

How to control the width and height of the default Alert Dialog in Android?

AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Title"); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { …
sat
  • 40,138
  • 28
  • 93
  • 102
92
votes
15 answers

gen already exists but is not a source folder

I am developing my Android project, After I removed a unused library, I got the error: myproject/gen already exists but is not a source folder. Convert to a source folder or rename it In my Activity code, all resources from R.java can not be…
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
89
votes
8 answers

How to fire onListItemClick in Listactivity with buttons in list?

I have a simple ListActivity that uses a custom ListAdapter to generate the views in the list. Normally the ListAdapter would just fill the views with TextViews, but now I want to put a button there as well. It is my understanding and experience…
CodeFusionMobile
  • 14,812
  • 25
  • 102
  • 140
87
votes
9 answers

Android - Get value from HashMap

I have tried to search on HashMap in Android, but getting problem: Consider this example: HashMap meMap=new HashMap
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
86
votes
3 answers

How to show one layout on top of the other programmatically in my case?

My main layout main.xml simply contains two LinearLayouts: The 1st LinearLayout hosts a VideoView and a Button, The 2nd LinearLayout hosts an EditText, and this LinearLayout has set the visibility value to "GONE" (android:visibility="gone") like…
Mellon
  • 37,586
  • 78
  • 186
  • 264
85
votes
3 answers

Does Android XML Layout's 'include' Tag Really Work?

I am unable to override attributes when using in my Android layout files. When I searched for bugs, I found Declined Issue 2863: "include tag is broken (overriding layout params never works)" Since Romain indicates this works in the test…
Eric Burke
  • 4,422
  • 3
  • 28
  • 29
83
votes
2 answers

How to set focus to a button widget programmatically?

Is it possible to set a focus to a button widget which lies somewhere down in my layout? onCreate of the activity my control/focus should be on that button programmatically.
Vinayak Bevinakatti
  • 40,205
  • 25
  • 108
  • 139
81
votes
3 answers

Android Lock Screen Widget

A few users have been asking me Android lock screen widgets for my app - I believe they want a widget that stays on their lock screens and allows them to interact with the app. I haven't been able to find any official documentation for this - the…
psychotik
  • 38,153
  • 34
  • 100
  • 135