Android SeekBar within a homescreen Widget - android

I am looking to find a way to add a SeekBar to a homescreen widget. After reading this post on StackOverflow, I found that SeekBar's are not supported within a RemoteView, because it is a descendant of a ProgressBar. (Descendants of the accepted widgets are not supported)
Though, in my project, I am using Lars Werkman's HoloColorPicker found here. If you notice in the src, his OpacityBar (which is essentially a SeekBar) extends a View. Since all the accepted widgets (here) are descendants of View, I would think this would work. But alas, upon trying to load the homescreen widget with the OpacityBar, it shows up with the "Problem loading widget" response.
Does anyone know why this doesn't work? And know how to make it work?
Or does anyone know how to get a working SeekBar within a homescreen widget?
Thank you!

Since all the accepted widgets (here) are descendants of View, I would think this would work
I have no idea why you conclude that, as it it is a logical fallacy. According to your logic, since negative numbers are types of number, all numbers are negative.
Does anyone know why this doesn't work?
Because you cannot use custom Views, or anything else not supported by RemoteViews, in an app widget.
And know how to make it work? Or does anyone know how to get a working SeekBar within a homescreen widget?
Write your own home screen, and implement whatever you are trying to do with the SeekBar in that custom home screen.

Related

Custom fonts for home screen widget TextView in android

the issue I face seems to have no solution and to be downright impossible to rectify, but I thought to ask here just in case I am missing something.
I need to display some text in an android widget using a non-system, non-standard font from assets folder.
Unfortunately, android does not allow extended view definitions in home screen widgets. Nor I can invoke a corresponding API method (setTypeface) from within the widget.
Does anyone know if there's any other alternative way to accomplish this?
(It seems quite natural to be able to customise text view appearance not only in the app but in widgets too, but it turns out to be impossible).
I'd appreciate any help on this.
Thank you...
Have you seen this link yet?
What is needed is to render the font onto a canvas, and then pass it
on to a bitmap and assign that to an imageview.
How to use a custom typeface in a widget?
By the way, you've asked 18 questions and have not accepted a single answer. I suggest you start accepting some or people will be less inclined to help you.

Creating a custom ui element and making it respond to user input

I have a volume knob and would like to know how to make it respond to user input in android. Please point me in the right direction as i have no idea how i can go about it ? Custom Knob looks like something created in this article. My question is what would be the general approach to port this knob into an android application. Do i have to extend the view class and draw this as a Bitmap. If so how exactly would i respond to user input. If this is not possible and i am on the wrong track could someone please tell me how to achieve this?
I would extend the View class.
View is the baseclass for widgets in android (by widgets I mean textfields, buttons, etc), so I think a volue knob would fit right in among those. About the user input, I'm not so sure. I think it depends on how you want to control the knob. I think looking at the onTouchEvent(MotionEvent) would be a good start. My guess is that you will need to overload a similar method anyways.
Related links:
http://developer.android.com/reference/android/view/View.html
http://www.vogella.com/articles/AndroidGestures/article.html

Using a Widget in Activity

it's me again :-)
Is there a way to use a widget (for home screen) in my own activites?
i think the homescreen is made with java, too?!
i do not want to change thinks in the widget, i still want to display them.
Regards
FLy
If you are looking to "re-use" a widget's layout and may be its base code, that is possible. I don't think it will be a good idea [or possible] to display a widget as an activity.
There are a lot of limitations in the number of view elements that can be used inside a widget. And again the way you will update a widget [RemoteViews] is actually very different from that of an Activity.
So in short, the answer would be a "NO".
Edit: This question has also been asked and answered a lot of times: difference between view and widget

Android clickable panel UI

I am currently working on an Android app, I have completed all the 'hard stuff', such as getting my database working, and so on. Now I need to make the UI look decent.
I would like to make something that has a 'frame' layout that is clickable. You would click on a 'frame' to find out more information, a bit like the Amazon app.
If anyone has any ideas, tutorials or good links, I would be very grateful.
Thanks in advance.
Take a look at Gallery. It's built in to Android and does what I think you're looking for (at least, it describes the Amazon app's UI; since FrameLayout has a very explicit meaning in Android that is not at all what you're talking about, I ignored that part).
EDIT: A screenshot would have been helpful but I think you're actually talking about a simple list-like view.
Oh. That's either a ListView, or more likely just a vertical LinearLayout inside a ScrollView. I can tell you what I'd do: Each item in the LinearLayout would have a background set, with a width of match_parent and a height of wrap_content, using a 9patch with the right-pointing arrow inside it. I'd also define an identical but blue-highlighted version of the image for the pressed state and use a state drawable XML to let it know which to use. Then I'd just bind an onClick listener for each item I wanted to fire off a click action on.

Should one use an Activity or a Service when using a button in a Widget?

I'm been trying to figure this out for a while now, and have just become more and more confused.
I have made a Android Widget which displays two articles (title + image). In addition to this, I have buttons for flipping backward and forward through the articles. What I don't understand is how I can change the Widgets RemoteViews when the buttons are pressed. Which should be one of the most basic operations in a widget, however, I can't seem to figure it out.
So...
Can I do this with just a OnClickListener in the AppWidgetProvider?
Or do I have to create an Activity without a window (visibility = false)?
Please excuse my stupidity. This is probably very basic.
I don't think this is basic at all - it's something I thought about for a while in relation to the Headset Blocker app I wrote, which is just a widget that you toggle on/off.
I ended up looking through Google's source code for what they did. The answer is to use the AppWidget's receiver nature to receive updates via setOnClickPendingIntent(). Then in onReceive(), you react differently to your own clicks than someone trying to create a widget. You can see a sample of what I did in the Headset Blocker source.
Ultimately, an Activity or a Service is too heavy weight for what you want. Using the same BroadcastReceiver as the app widget itself is much better.

Categories

Resources