Redrawing Widget When Changing Orientation

by Matt M » Tue, 27 Apr 2010 05:03:42 GMT


Sponsored Links
 Hello,

I have a widget set up and it displays properly in both portrait and
landscape when added to each. But when I change orientation it has the
problem "Problem Loading Widget". I delete this, re-add the widget,
and it displays correctly. Thus, my widget can support both portrait
and landscape but it doesn't survive an orientation switch.

What am I missing? Do I need to redraw the widget when orientation is
changed? Doesn't it do this automatically? Do I need to call
onUpdate() somehow?

Thank you!

Matt.

--



Redrawing Widget When Changing Orientation

by Matt M » Wed, 28 Apr 2010 08:20:06 GMT


 I've discovered the method call that causes the problem but I still
don't understand why..

In an activity, after saving and exiting I make a static method call
MyAppWidget.forceUpdate(this, "text");

Below is the method which updates the text of the widget
    public static void forceUpdate(Context context, String note)
    {
        if (context != null)
        {
                ComponentName thisWidget = new
ComponentName(context,WhiteboardWidget.class);
                AppWidgetManager manager =
AppWidgetManager.getInstance(context);
                RemoteViews views = new
RemoteViews("whiteboard",R.layout.widget_layout);
                views.setTextViewText(R.id.boardNote, note);
                manager.updateAppWidget(thisWidget, views);
        }
    }

Any ideas now??

--


Sponsored Links


Other Threads

1. Dynamically added ImageView pacement

Hey all,

I'm trying to add ImageView's dynamically, and I want them to be
placed next to each other.  Everything I try just puts them on top of
each other:

      for (int i=0; i < num_photos; i++) {

            ImageView iv = new ImageView(this);
            iv.setLayoutParams(new LayoutParams(45, 45));
            iv.setAdjustViewBounds(true);
            iv.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            iv.setPadding(0, 0, 0, 0);


            RelativeLayout rl = (RelativeLayout) findViewById
(R.id.rl);

           //I've tried:
            rl.addView(iv);

           //I've tried:
            rl.addView(iv, 2);

           //I've tried:
            rl.addView(iv, new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));

        }


Any ideas?  Thanks in advance...

-- 

2. Cannot download SDK with eclipse 3.5 in ubuntu 9.10.



I'm having the same issue, via both http and https. Running Eclipse
3.5 and OS X 10.6.2. I have everything installed except the 0.9.4 ADT
plugin. I'm getting a Droid tomorrow so would really like to get this
working! :)

-- 

3. can't launch intent + debug problem, Source not found

4. What the actual meaning of Eclair?

5. HTC Eris no longer sending X_WAP_Profile header

6. Android SDK 2.0 Java API does support OPP?

7. What's the deal with android.intent.category.DEFAULT?