Can I change appwidget-provider XML 's android:initialLayout? How to do?

by Perry168 » Fri, 20 May 2011 09:30:39 GMT


Sponsored Links
 Hi all,

    Following was the appwidget-provider XML for my widget. About the
< android:initialLayout="@layout/sc1" >, how to change the "@layout/
sc1" value in activity(Java)? e.g. change the sc1 to sc2.
    From this , I hope my widget is more flexible to use different
layout.

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
        xmlns:android=" http://schemas.android.com/apk/res/android" ;
        android:minWidth="150.0dip"
        android:minHeight="150.0dip"
        android:updatePeriodMillis="0"
        android:initialLayout="@layout/sc1"
        android:configure="com.test.runningtest.Setting"
        >
</appwidget-provider>

Thanks a lot!

-- 



Can I change appwidget-provider XML 's android:initialLayout? How to do?

by Perry168 » Fri, 20 May 2011 09:30:39 GMT


 Hi all,

    Following was the appwidget-provider XML for my widget. About the
< android:initialLayout="@layout/sc1" >, how to change the "@layout/
sc1" value in activity(Java)? e.g. change the sc1 to sc2.
    From this , I hope my widget is more flexible to use different
layout.

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
        xmlns:android=" http://schemas.android.com/apk/res/android" ;
        android:minWidth="150.0dip"
        android:minHeight="150.0dip"
        android:updatePeriodMillis="0"
        android:initialLayout="@layout/sc1"
        android:configure="com.test.runningtest.Setting"
        >
</appwidget-provider>

Thanks a lot!

-- 


Sponsored Links


Re: Can I change appwidget-provider XML 's android:initialLayout? How to do?

by Mark Murphy » Fri, 20 May 2011 18:08:15 GMT


 Just use your desired layout on the first onUpdate() call of your
AppWidgetProvider. You cannot literally modify android:initialLayout,
or anything inside of a resource, at runtime.






-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

Android App Developer Books:  http://commonsware.com/books 

-- 



Other Threads

1. No callback when list item is touched.

I have a ListView that is populated with a custom adapter.  When an
item is clicked with the trackball, it works fine, i.e. I can catch
the event and move on, though when I touch an item with my finger
there is no callback from the listener.  The item does respond to the
touch, by turning orange for that moment.

Here is how I've setup the listener.  This is within an Activity, not
a ListActivity.

                 list.setOnItemClickListener(new
AdapterView.OnItemClickListener() {

                                        public void onItemClick(AdapterView<?> 
arg0, View arg1,
                                                        int position, long id) {
                                                viewItem(id);

                                        }
                         });

What am I missing? Is there another listener I need to configure?
--~--~---------~--~----~------------~-------~--~----~

2. OnGestureListener vs ContextMenu, do they play together?

It's likely the wrong way, but what you described works for me. I am showing
the context menu manually.







--~--~---------~--~----~------------~-------~--~----~

3. TabHost and Scrollbars

4. need some collection help

5. Bouncing ListView?

6. emulator versus real target...

7. Create Drawable IDs in a loop??