Frage

I have a J2ME LWUIT app and I'm trying to change the width and background color of a button. The button is in a BoxLayout. I'm using code like this:

    btnLogout.setPreferredW(210);
    btnLogout.getStyle().setFgColor(0x00dcc5);
    btnLogout.getStyle().setBgColor(0x302d36);

Only the setFgColor line seems to work. The width remains unchanged and the background remains white. How can I change the style of the button? I haven't had this problem with other components (labels, text fields, etc...)

War es hilfreich?

Lösung

If you are using the nokia sdk 2.0 to build your app, you should know that the Button's and native elements (Checkbox, ComboBox, etc)style is predefined by the system, so you can't change the native background using this methods.

I don't recommend you to change this values. If you want to build an app following the Nokia S40 guidelines, you must keep the native elements as they are.

If you still want to change this background.

You must open the .res file attached to your project (if you have made a custom .res...if you are using the .res from the Nokia sdk...you must find the source code for the library (is nokia page) and there you can find the .res). In the .res file you can create a new style for your custom Button, and later in the code you must set it to your Button, using the setUIID method in your component....with the name that you have set in the .res file.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top