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. FileObserver not returning file changes within subfolders?

The FileObserver class doesn't appear to be working as advertised.

I created a class extending the FileObserver class.  I initialize the
class to watch the path of the sdcard as returned from the Android
Environment.getExternalStorageDirectory function.  Everything seems to
work perfectly as long as the files are in the ROOTof the sdcard.  Any
files within SUB-FOLDERS of the sdcard are NOT returned to my public
void onEvent(int event, String path) callback in my FileObserver
class.

Has anyone seen this issue?  The docs say files in subfolders should
be returned to the onEvent() callback but it's not happening.  Note,
I've only tested on the Android simulator (v2.2) since I do not yet
have access to a device.  Maybe this is a bug specific to the
simulator?

Thanks!

-- 

2. Manipulating SIM card or SD card pins

Hi,

I am trying to write a program that will be able to read digital
signals from the SD card slot or SIM card. Unfortunately, the computer
I am working on is a bit slow and and I am just starting and not very
familiar with the android platform.

Does this code look right?
Thanks!




package sim.ReadBitstream;

import android.app.Activity;
import android.os.*;
import android.widget.TextView;
import android.content.*;
import java.io.*;

public class ReadBitstream extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);




        int count=10;           //Determine the amount of bytes to read

        File SimAccess = new File("content://icc/sdn");
        byte ADC[] = new byte[count];

        FileInputStream StreamRead = new FileInputStream(SimAccess);    //Read
the stream from the SIM card
        StreamRead.read(ADC, 0, count);


    }
}

-- 

3. Class Object and Messenger/Bundle

4. new screen on button click

5. Unit testing a class that uses android.os.Handler

6. Question For All Android Developer

7. Custom ListView Contain ImageView + TextView + CheckBox for selected Row