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. MediaRecorder: capture failure

Hi,
I am trying to run MediaRecorder code snippet from Develope's
documentation, on emulator at this time:
try {
                                        MediaRecorder recorder = new 
MediaRecorder();
                                        
recorder.setAudioSource(MediaRecorder.AudioSource.MIC); - doesn't
work at all
                                        
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
                                        
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
                                        
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
                                        recorder.setOutputFile("/sdcard/cap");
                                        recorder.setVideoSize(176, 144);
                                        recorder.setVideoFrameRate(10);         
        
                                        
//recorder.setPreviewDisplay(surfaceHolder.getSurface());
                                        
//panelPreview.setVisibility(LinearLayout.VISIBLE);

                                
                                recorder.prepare();
                                recorder.start();
                        }
                        catch (Exception e)
                        {
                                
                                Log.d("!! EXCEPTION: ", e.getMessage());
                        }

i have the following errors on "recorder.prepare()" :

02-06 09:46:56.879: WARN/MediaProfiles(34): could not find media config xml file
02-06 09:46:57.599: ERROR/CameraInput(34): Unsupported
parameter(x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value)
02-06 09:46:57.599: ERROR/CameraInput(34): VerifiyAndSetParameter
failed on parameter #0
02-06 09:46:59.219: WARN/AuthorDriver(34): Video encoding bit rate is
set to 320000 bps
02-06 09:47:01.879: DEBUG/CameraHardwareStub(34): initHeapLocked:
preview size=320x240
02-06 09:47:01.929: ERROR/CameraInput(34): No surface is available for display
02-06 09:47:01.929: ERROR/AuthorDriver(34): Command 13 completed with error -1
02-06 09:47:01.929: ERROR/MediaRecorder(282): prepare failed: -1

What is "media config xml " file - do i need special config file for
MediaRecorder ? docs don't mention it?
What is the meaning of  "No surface is available for display"  error message?

Thank you,
-V

-- 

2. android MediaPlayer not playing mp3 file

I have written the most basic application I can think of to try to
play an mp3 file, but it is not working. I don't get any errors, but
when the application starts up, the sound is not played.

<pre>
<code>
public class soundtest extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MediaPlayer mp = new MediaPlayer();
        mp.create(getApplicationContext(), R.raw.norm_iphone_money);
        mp.start();
    }
}
</code>
</pre>

What am I missing? I have "norm_iphone_money.mp3" inside the res/raw
folder. The file plays fine in Windows Media Player and iTunes.

I'm using the latest versions of Java SDK and Eclipse for Java. The
app is targeted for Android 2.2 and runs fine in the emulator despite
no sound.

-- 

3. Receive Bluetooth Push

4. palm swipe delete; feature request

5. Android MVC Framework

6. Android Market Website - Installs!

7. Music / Soundtrack composer available for interesting game projects - perhaps even free