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. How to get the version of installed apps

Hello all,

How can I get the version information of the current installed apps on my
phone.

If I do :

PackageManager packageManager = getPackageManager();
List<PackageInfo> packs = packageManager.getInstalledPackages(0);
int size = packs.size();
apps += "\nTotal apps = "+ size+"\n";
for (int i = 0; i < size; i++)
{
PackageInfo p = packs.get(i);
apps += "\nApp name: " +
p.applicationInfo.loadLabel(packageManager).toString();
apps += "\nPackage name: " + p.packageName;
apps += "\nVersion name: " + p.versionName;
apps += "\n";
 }
tv.setText("Installed apps:\n"+apps);

I get all the apps currently installed.

I wasn't able to figure out how to extract their correspondent version
information.

Any suggestions?

Thanks.

-- 

2. Accessing APNs on the phone

Hello,

How can I get the information on this phone regarding its number, carrier,
etc?

I have tried this:

String names = "";

Uri contentUri = Uri.parse("content://telephony/carriers/");

Cursor cursor = null;
try
{
cursor = getContentResolver().query(contentUri, new String[]{"name"}, null,
null, null);
if (cursor != null)
{
while (cursor.moveToNext())
{
String name = cursor.getString(0);
names+= name + "\n";
}
}
}
catch (Exception ex)
{
//Handle exceptions here
}
finally
{
if (cursor != null) cursor.close();
}


tv.setText("TestActivity:\n"+names);

But no success.

I get on the emulator screen:
Android
TelKila

-- 

3. Why does TextView.setText cause the enclosing ScrollView to scroll?

4. How to fetch phone's phone number or unique ID

5. The server could not process your apk. Try again.

6. Build-In Extensions

7. Google MapsAPI MyLocationOverlay causes ClassCastException