Digitalclock in widget

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Digitalclock in widget

Postby blackgin » Tue Sep 22, 2009 9:07 pm

I tried to use digitalclock in layout.main for a widget. But the widget fails to load.
Could someone explain why or how could I solve?
User avatar
blackgin
Developer
Developer
 
Posts: 33
Joined: Tue Apr 21, 2009 1:21 pm

Top

Postby blackgin » Thu Sep 24, 2009 5:15 pm

Does nobody could help?
User avatar
blackgin
Developer
Developer
 
Posts: 33
Joined: Tue Apr 21, 2009 1:21 pm

Postby yaj786 » Thu Sep 24, 2009 7:44 pm

We need to see some code before we understand whats wrong.

Let's see your declaration in the xml file.
yaj786
Developer
Developer
 
Posts: 33
Joined: Fri Jul 10, 2009 7:37 am

Postby blackgin » Thu Sep 24, 2009 10:00 pm

<DigitalClock
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>

If I run this code into an activity it shows the clock, but not in the widget
User avatar
blackgin
Developer
Developer
 
Posts: 33
Joined: Tue Apr 21, 2009 1:21 pm

Postby yaj786 » Thu Sep 24, 2009 10:52 pm

From the dev guide:
Creating the App Widget Layout

You must define an initial layout for your App Widget in XML and save it in the project's res/layout/ directory. You can design your App Widget using the View objects listed below, but before you begin designing your App Widget, please read and understand the App Widget Design Guidelines.

Creating the App Widget layout is simple if you're familiar with Declaring Layout in XML. However, you must be aware that App Widget layouts are based on RemoteViews, which do not support every kind of layout or view widget.

A RemoteViews object (and, consequently, an App Widget) can support the following layout classes:

FrameLayout
LinearLayout
RelativeLayout
And the following widget classes:

AnalogClock
Button
Chronometer
ImageButton
ImageView
ProgressBar
TextView

Descendants of these classes are not supported.
yaj786
Developer
Developer
 
Posts: 33
Joined: Fri Jul 10, 2009 7:37 am

Postby blackgin » Fri Sep 25, 2009 11:03 am

So, how could I replace digital clock? I tried with a textview with Time.hour and Time.minute
But it didn't update altought I set updatePeriod in widget metadata
User avatar
blackgin
Developer
Developer
 
Posts: 33
Joined: Tue Apr 21, 2009 1:21 pm

Top

Postby Funfactor » Sat Sep 26, 2009 5:15 pm

I'm not shure I get the problem you have. But I tried the ressource definition

<DigitalClock
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>

and the widget appears in the UI. Certainly you will have to control the widget within your program.

Regards,
Stefan
Funfactor
Freshman
Freshman
 
Posts: 6
Joined: Wed Jul 09, 2008 3:02 pm

Postby blackgin » Sun Sep 27, 2009 9:40 am

I don't want to show the clock into an activity, but into a widget (homescreen widget)
User avatar
blackgin
Developer
Developer
 
Posts: 33
Joined: Tue Apr 21, 2009 1:21 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 6 guests