Actually I was seeking for a solution to display gauge widget in Android AppWidget.
Inorder to display Gauge package in Home screen widgets like weather widgets in our mobile home screens.
I recommend you to take a look at this documentation.
It explains how to achieve what you were looking for.
After you make the skeleton then you can use the custom gauge widgets.
An app widget uses RemoteViews for describing its UI, and RemoteViews supports a limited number of built-in widgets. You cannot use a custom View subclass directly. After all, your app is not rendering the UI — whatever app has the home screen implementation is rendering the UI, and that app does not have your custom View subclass.
The closest thing that you can do is to put an ImageView in your app widget's layout, then populate that ImageView with bitmaps that depict what you want to show in terms of a gauge UI.
Related
You can see a list of views that are capable of remote views:
absolutelayout-framelayout-linearlayout-relativelayout-analogclock-button-imagebutton-iamgeview-textview
and other controls.
My question is:
Is there any way to create a custom view that be capable of remoteviews?
Is there any way to create a custom view that be capable of remoteviews?
If, by this, you mean "is there any way to create a custom View that a RemoteViews can use?", at best the only way that is possible is if both apps have that class. So, for example, if you wrote the home screen, and you wrote the app that is publishing an app widget, so you can arrange for your custom View to be in both apps, then maybe you can include that custom View in the layout used as the starting point for the RemoteViews. It's possible that the way RemoteViews inflates the layout that even this approach will not work, though.
I am new to android development, and we have a very specific requirement.
We need to change the content/layout/flow of the app on the fly. For e.g. we have a layout which consists of some images, textarea and textboxes. There might be a request coming to change the textarea to a textbox.
We thought about this and are thinking to provide the apk with a json/xml which will contain all these changes.
My question is will it be possible to re-draw the objects again dynamically and change the content?
Yes this is possible. You can dynamically design what has to be displayed in your Activity UI screen. If you feel there are only 2 or 3 different UI screens that would be repeatedly used, then you can have XMLs for these screens and you can just change their labels in OnCreate() of Activity class before rendering. LayoutInflater class would be helpful here.
When you design a Android Application with Activities and Fragments your XML layout definition is always static. If you want a true dynamic layout structure you should use a Web View with a HTML content pointing some URL.
As Rahul says, another approach is to manage the "default cases". For me that is the standard way to design an Android Application.
The dynamic content (values) can be done with a simple http call to server you can get values for your views.
The navigation could be handled by switching Intents, but, definitively you have to associate these intents to UI elements like buttons in the most cases, and ¿How you can do that if your layout is changing over time?.
I think, that the WebView could be a very easy solution for your problem.
A bit new to Android. I am trying to create a home-screen widget that lets you change ringtone or music volume, using the SeekBar View. I was reading on widgets in http://developer.android.com/guide/topics/appwidgets/index.html, and was surprised to come across a section, "Creating the App Widget Layout," that says only certain classes can be handled by a RemoteViews object, and thus only these can be used in a home-screen widget. The ProgressBar class is supported, but the documentation explicitly says descendant classes are not supported. Since I am trying to create a SeekBar in my widget, which is a descendant of ProgressBar, is this impossible via RemoteViews? If so, is there another method to create widgets which does not rely on RemoteViews? Thanks in advance for any help.
Since I am trying to create a SeekBar in my widget, which is a descendant of ProgressBar, is this impossible via RemoteViews?
Correct.
If so, is there another method to create widgets which does not rely on RemoteViews?
No. You can write your own home screen app, though, and there you can use whatever you want on the home screen, since it is your own app.
We're designing an application that displays several hundred graphical elements on a single screen that need to respond to touch events and that can be animated -- however, they are not full-blown widgets (no focusing and other event handling). Is the View class appropriate for this, or is there a more lightweight class we should use?
(For those familiar with the Qt Framework, we're looking for something like the QGraphicsItem class)
View is just fine. It provides the full functionality and flexibility you may need to obtain graphical elements.
I am building a home screen widget and I want to add an advertisement to it. Currently the advertises SDK provides a custom view widget which I tried to embed in my home screen widget. But when I add it, it says problem loading widget. I'm guessing I can't add custom views to a widget? Could someone clarify or tell me how I could add an advertisement to my home screen widget.
Thank you
Home screen widgets support very limited number of standard widgets. You can't use custom widgets for them. See App Widgets.