How can I specify the default style of my widget

by Meryl Silverburgh » Fri, 13 Feb 2009 08:16:16 GMT


Sponsored Links
 Hi,

I create my own widget with its own drawable for background.

So in my styles.xml file, I have this:
<resources>
      <style name="MyWidget">
        <item name="android:background">@drawable/btn_mywidget_bg</item>
    </style>
</resources>

In my main.xml, if i specified my 'style' attribute, my background
drawable was displayed correctly.
 <test.MyWidget android:id="@+id/mywidget" style="@style/MyWidget" />

but if I just do this:
<test.MyWidget android:id="@+id/mywidget" /> , the background drawable
is not display correctly.

Can you please tell me how can I specify the default style of my
widget so that I don't need to add style="@style/MyWidget" everytime I
 use my widget?

Thank you.

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



Other Threads

1. Pass Array from Java to C (over JNI) work in an activity but fail in a thread?

Hi! All:

I've stuggle of this problem few days, search many hours but not sure
what's I should try.
Thanks in advance.
I have a native c function which take jintarray as a parameter, and I
wanna pass a int array to it.
I use  GetIntArrayRegion to copy out the content of jintArray.

JNIEXPORT jstring Java_com_google_client_DecodeThread_test( JNIEnv*
env,
                                      jobject  this,    jintArray
verts1 )
{

jint buf[307200];
(*env)->GetIntArrayRegion(env, verts1, 0, 307200, buf);
}

It seems work when I call this native function in an activity. (it
didn't crash ,at least)
But it always crash when I call this native function in an thread
which will be called in an activity.

I can't figure out why is that...
I saw many example, they just pass jintarray...

I also found that If I copy small part of the jintarray, it won't
crash.

Is there any memory limit of thread ?
or something related to GC and invalid array pointer?

The following is part of my code.
Thanks a lot for your help.

in java:
public native int testmem(int[] img);

private void decode_c()
  {
...
System.loadLibrary("mydecoder");
int[] img_int = new int[307200];
int res= test(img_int );   ----------> it will crash here.I can't even
find out the error, the application closed.
...
}


in native c:

JNIEXPORT jstring Java_com_google_client_DecodeThread_test( JNIEnv*
env,
                                      jobject  this,    jintArray
verts1 )
{

jint buf[307200];
(*env)->GetIntArrayRegion(env, verts1, 0, 307200, buf);
  return (*env)->NewStringUTF(env, "show when no crash!");
}

2. Accessing Email Attachments

I am trying to access an email attachment, what is the best
approach?

I have tried using a content provider like "content://
com.android.email.attachmentprovider", but i get a security
exception.  When i add a permissions like

<uses-permission
android:name="com.android.email.permission.READ_ATTACHMENT"></uses-
permission>

I still get the security exception.

Is there some other uses-permissions that i need to use?  Or is there
another better way to access an email or email attachments?   Do I
need to write my own email client?  If so, then where do i start to do
this?

thx for any help

Joe C

3. How to animate between two instances of the same activity?

4. How to add footer and Header to a list

5. telnet to localhost:5554 prompts for password

6. play video file inside the triangle using opengles - andorid

7. Classloader same on Android as JavaSE