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
57
votes
9 answers

Why can't one add/remove items from an ArrayAdapter?

I am using an ArrayAdapter to populate the items to list in a android.widget.Spinner. That works all fine. But now I want to keep the list of items dynamic, i.e. I want to be able to add/remove items from the selection list at runtime.…
mmo
  • 3,897
  • 11
  • 42
  • 63
56
votes
20 answers

"_Problem Loading Widget" message

When loading a widget if it cannot find a resource or something it says Problem Loading Widget. That's all! Amazing! This message remains on the home screen and does not even say which widget it had trouble loading. I figured it out by trial and…
Androider
  • 21,125
  • 36
  • 99
  • 158
55
votes
11 answers

Using selector to change TextView text color

I'm trying to use a TextView to define the style of a TabWidget on a tabhost. I just created a selector for bgcolor and works fine, but i want to make a selector for textColor but the text color don't change: This is my tab_text_selector.xml:
Rafael Carrillo
  • 2,772
  • 9
  • 43
  • 64
55
votes
14 answers

How to get screen width and height

I tried to use following code to get screen width and height in android app development: Display display = getWindowManager().getDefaultDisplay(); int screenWidth = display.getWidth(); int screenHeight = display.getHeight(); but I got…
Leem
  • 17,220
  • 36
  • 109
  • 159
55
votes
11 answers

Android how to focus ActionBar searchView

Hello i need to put some text inside the searchView and focus/expand the searchView widget. this is what i tried but it doesn't work @Override public boolean onCreateOptionsMenu(final Menu menu) { ... SearchView searchView = (SearchView)…
max4ever
  • 11,909
  • 13
  • 77
  • 115
53
votes
11 answers

Pop up window over Android native incoming call screen like true caller Android app

I am developing a broadcast receiver for incoming calls in Android and on getting incoming calls I want to inflate a pop up over the native incoming call screen. I completed that code. But now the problem is that in the Android 4.1 (Jelly Bean) API…
53
votes
7 answers

Set underline text to TextView in android programmatically

I want to know how to set underline text to TextView in android? Please make a note that I don't have capability to set a strings.xml with pre-populated strings is there any way to add it with pure java code in Android.
Pratik Patel
  • 551
  • 1
  • 4
  • 6
53
votes
7 answers

Open source Android libraries? Reusable Views, ViewGroups, Adapters etc?

Here's what I really want: a site collecting re-usable components for Android. I have found various small lists, the biggest being the Open Intents library list. Mark Murphy (hi, Mark) also lists the library projects he publishes. None of this is of…
jamesh
  • 19,863
  • 14
  • 56
  • 96
52
votes
1 answer

Custom Widget using LinearLayout not getting onDraw()

I'm creating a custom widget by extending LinearLayout: public class MyWidget extends LinearLayout { private static Paint PAINT = new Paint(Paint.ANTI_ALIAS_FLAG); static { PAINT.setColor(Color.RED); } public…
Steve Pomeroy
  • 10,071
  • 6
  • 34
  • 37
50
votes
14 answers

How to fix "process is bad" error for an Android Widget?

I have developed an Android Widget, and it was working fine. I added some extra functionality and pushed an update through the Android Market. Now people are complaining that it doesn't work anymore. The error I see in the logs is: 07-14…
wligtenberg
  • 7,695
  • 3
  • 22
  • 28
50
votes
7 answers

Button click event for android widget

I have an android widget that fetches data from a server every 10 minutes and display's it on the screen. I'd like to add a "Refresh" button to that widget. When the user clicks that button I'd like to run the method that fetches the information…
Sharon Haim Pour
  • 6,595
  • 12
  • 42
  • 64
48
votes
6 answers

implement android:src="@drawable/image" programmatically in Android

I am trying to set the foreground image on an image button. After some research, I came across this code sample:
user788511
  • 1,726
  • 2
  • 30
  • 52
48
votes
11 answers

EditText hint doesn't show

My EditText configured as follows won't show the hint:
venuko
  • 481
  • 1
  • 4
  • 3
48
votes
4 answers

How can an error message be set for the Spinner in Android?

I'd like to be able to call code like this, similar to how setError is set on a TextView: spinner.setError("Error message"); However, setError only works for an EditText, not for a Spinner. I want to notify the user if the spinner field is not…
Gopinath S
  • 518
  • 1
  • 4
  • 12
47
votes
4 answers

Setting attribute of child element of included layout

I have a main.xml file describing the layout of my main activity:
Matthew
  • 6,356
  • 9
  • 47
  • 59