How to change item's style at run-time using J2ME Polish - java-me

How can I change item's style at runtime using J2ME Polish?
I'm trying the following code but I'm unable to get it working.
Style style = new Style();
style.addAttribute("background-color", "#FF0000");
item.setStyle(style);

Style style = new Style();
style.background = new BorderedSimpleBackground(0xF0F0F0, 0xFF0000, 1);
item.setStyle(style);

Related

Custom controls not visible in the View

Below is my code I used to create a custom UITextField in code behind.
UITextField usernameField;
usernameField = new UITextField
{
Placeholder = "Enter your username",
BorderStyle = UITextBorderStyle.RoundedRect,
Frame = new RectangleF(10, 32, 50, 30)
};
View.AddSubview(usernameField);
But when I run my app, I dont see this anywhere. Not only this control but all the controls that I create in code behind.
If I drag the controls from toolbox onto my View it's working very fine.
What might be the cause?
Make sure that Container View is not transparent so Alpha = 1 and set background colors for appropriate controlls. Because by default its set to ClearYou can use this method to easly set background and rounded corners like in older versions of iOS
public static void MakeViewRounded(UIView view,float cornerRadius, MonoTouch.CoreGraphics.CGColor backgroundColor)
{
view.Layer.CornerRadius = cornerRadius;
view.Layer.BackgroundColor = backgroundColor;
}
Also make sure that you adding your custom controll to ViewController/View

How to change hint text font size and color in j2me using LWUIT?

I am using the following code in java file and not using resource file.
m_txtSearch = new TextField();
m_txtSearch.setHint("Search");
Then how can i change the font size and color of hint text ?
Can u please help me ?
Font font = new Font("Verdana", Font.BOLD, 12);
txt.setFont(font);
txt.setForeground(Color.BLUE);

TextField dissapear in TableLayout in LWUIT Java ME

I've searched for this problem but still can not find the solution. By the way my level of Google Translate is ugly (I speak Spanish). Well, the thing is that I want my application form looks as follows:
Or maybe so:
The problem is that when I want to, text fields disappear
I do not know why is that.
Here is my code:
TableLayout tableLayout = new TableLayout(3, 2);
this.setLayout(tableLayout);
//this.addCommandListener(this);
TableLayout.Constraint colum1 = tableLayout.createConstraint();
colum1.setWidthPercentage(35);
lblCodigo = new Label("Codigo :");
this.addComponent(colum1, lblCodigo);
TableLayout.Constraint colum2 = tableLayout.createConstraint();
colum2.setHorizontalAlign(Component.LEFT);
colum2.setWidthPercentage(65);
txtCodigo = new TextField();
this.addComponent(colum2, txtCodigo);
TableLayout.Constraint span = tableLayout.createConstraint();
span.setWidthPercentage(100);
span.setHorizontalAlign(Component.CENTER);
span.setHorizontalSpan(2);
btnBuscar = new Button("Buscar");
//btnBuscar.setPreferredW(50);
this.addComponent(span, btnBuscar);
Well, I'm working with LWUIT 1.4, Java ME SDK 3.0.
I tried that with LWUIT 1.5.
Does anyone have an idea why the text boxes disappear?

Setting the navigation bar color in monotouch

I am attempting to write an application with MonoTouch. I need to set the background color of the navigation bar. I'd like to set it to orange. This seems like an easy task, but I can't seem to get it to work. Currently, I'm doing the following in the AppDelegate.cs file:
this.window = new UIWindow (UIScreen.MainScreen.Bounds);
this.rootNavigationController = new UINavigationController();
UIColor backgroundColor = new UIColor(74, 151, 223, 255);
this.rootNavigationController.NavigationBar.BackgroundColor = UIColor.Orange;
However, the navigation bar color is still the default color. How do I set the background color of the navigation bar?
You can do this on an ad-hoc basis as Rob described using the TintColor property:
this.rootNavigationController.NavigationBar.TintColor = UIColor.Orange;
Alternatively, you can also set the TintColor for all UINavigationBars at once using the UIAppearance proxy in iOS 5. This is usually done somewhere near DidFinishLaunchingWithOptions method in the AppDelegate:
UINavigationBar.Appearance.TintColor = UIColor.Orange;
You can check out the Apple doc for more detailed information and implementation restrictions:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAppearance_Protocol/Reference/Reference.html
Try changing the TintColor and Translucent properties.

How to style TextField component from properties in Flash CS5 professional

Hi
I am new to AS3.0, and what I am trying is to style Label, TextInput from the properties section show to the right.
But I couldnt find any alignment, font-size etc options.
How to style these components at design time, instead of AS3.0 code.
In AS3.0 you can apply these styles to your components with some lines of code. This is an example from Adobe Help
var tf:TextFormat = new TextFormat();
tf.color = 0x333333;
tf.font = "Georgia";
tf.size = 24;
tf.align = "center";
tf.italic = true;
textInput.setStyle("textFormat", tf);
More info here: http://goo.gl/dNCxe

Resources