Codename One - GridLayout in a RTL language - codenameone

Is it possible to automatically "mirror" a GridLayout in a RTL language? I mean that the first column should be on right instead of on left.
I tried it in my app without success.

It does work. I'm guessing you didn't activate the global RTL flag correctly you need to do that early on in the app for it to take effect.
Form hi = new Form("RTL", BoxLayout.y());
Container grid = GridLayout.encloseIn(new Label("1"), new Label("2"), new Label("3"));
Container gridRTL = GridLayout.encloseIn(new Label("1"), new Label("2"), new Label("3"));
gridRTL.setRTL(true);
hi.addAll(grid, gridRTL);
hi.show();

Related

Embedding material icons charcters in regular text in CodenameOne

Is there a way to inject a material icon character inside a regular text paragraph?
So I need something like this: "Some text"+material icon character here+" some more text". And I want this to flow normally, without extra lines.
Thanks.
I suppose that there are several approaches according to the level of generalization of this problem. For example, a complex solution could be an extension of the RichTextView class to support this feature (http://www.codenameone.com/blog/tip-rich-view-revisited.html).
However, a basic approach could be to have two or three Labels inside a Container with a FlowLayout layout. For example, the following code:
Form hi = new Form("Hi World", BoxLayout.y());
Container textWithMaterialIconInside = new Container(new FlowLayout(Component.LEFT));
textWithMaterialIconInside.add(new Label("Some text", "Label"));
textWithMaterialIconInside.add(new Label(FontImage.createMaterial(FontImage.MATERIAL_BACKUP, UIManager.getInstance().getComponentStyle("Label"))));
textWithMaterialIconInside.add(new Label("and other text", "Label"));
hi.add(textWithMaterialIconInside);
hi.show();
generates this content:

Change the style of a certain text of textarea

I've a textArea with grow limit "2" and alignment "center". I need to hightlight the "Quick Booking" text of the following textArea differently ie. in color, size etc. Since the textArea is aligned center, this hightlighted text may appear anywhere as per the device width. How can I do that?
TextArea ta = new TextArea("Need urgent fix for your car ? We will get to you asap Quick Booking");
ta.setUIID("small");
ta.setEditable(false);
ta.setGrowByContent(true);
ta.setGrowLimit(2);
ta.getAllStyles().setAlignment(Label.CENTER);
How It is now...
How it should be...
That isn't supported. One option is to use a BrowserComponent for this element and format it with HTML. Another is to use a rich text view such as this: https://www.codenameone.com/blog/tip-lightweight-rich-text-view.html
I saw the stack question where it was solved. I didn't find it now otherwise I'd have shared the link. It works though.
homeContainer.add(FlowLayout.encloseCenter(lbl1, new Label("urgent"), new Label("fix"), new Label(" for"), new Label("your"), new Label("car? "), new Label("We"), new Label("will"), new Label("get"), new Label("to"), new Label("you"), new Label("asap "), clickable));
I am afraid this is not supported.I would suggest you to give a look on below article
https://medium.com/#Cuong.Le/android-rich-text-overview-397e6af529d9

Codename1 side menu misplacement

I am trying to specify sidemenu width with the follow code:
Hashtable<String, Integer> h = new Hashtable<>();
h.put("sideMenuSizePortraitInt", 50);
h.put("sideMenuSizeLandscapeInt", 30);
UIManager.getInstance().setThemeProps(h);
But the result has some misplacement, please see the picture. Anybody knows how to fix this?
screenshot
That's a bad idea. This will break your theme entirely as it will replace all existing theming in the app. Theme constants are added in the designer tool by double clicking the res file, selecting the theme and then going to the 5th tab for the constants.
If you insist on doing this thru code I suggest using addThemeProps and not setThemeProps. Theme constants start with the # symbol to signify that they are constants.

Trouble referencing movieClips

I am working on a flash project that dynamically generates navigation from an XML. For now I am trying to get it to work with arrays so that I can adapt it to xml once I know the logic works. I am new to as3 and learning has been a tiny bit bumpy. I have been searching for a solution to this but many of the examples I have seen have either been too simple to answer my question or too complex to understand since I am on the new side. This is the code I am working with.
var clientList:Array = new Array("Client1","Client2","Client3","Client4","Client5","Client6","Client7","Client8","Client9","Client10","Client11","Client12","Client13","Client14","Client15");
for each (var cName in clientList){
var newClientBtn:btnClientNav = new btnClientNav();
newClientBtn.x = workX;
newClientBtn.y = workY;
workY += newClientBtn.height;
newClientBtn.mcClientName.text = cName;
lContent.mcWork.addChild(newClientBtn.name);
trace(newClientBtn);
}
I can't fingure out how to properly refernce the dynamically created clips. I have a dynamic text box in the button but can't figure out how to reference it properly to change it, then my next issue will be referencing the buttons to make rollover and click code. I know this probably something simple to fix but I have been looking at it for too long and my eyes are starting to cross.. Thank you in advance for any advice you can give.
Why not store the clips you are creating in an object you can access later?
If you want to reference a movie clip by name though, one way to do it is:
var referenceMC:MovieClip = MovieClip(containerMC.getChildByName(“targetMC”));
If it was a text field or a button you were after, I believe you would do the same but instead cast the result of getChildByName to your desired control.
I also believe you want to add the button itself as a child, not pass its name into your addChild call?

Microsoft Surface: Adding IdentityTag to TagVisualizer shows a cross-hair. Why?

in my Surface application happens this:
When I put an IdentityTag onto my TagVisualizer, a white cross-hair appears. This TagVisualizer adds no TagVisualization when adding a Tag, it just calls some methods in its "VisualizationAdded"-Event.
In my other TagVisualizers before there were no cross-hair but they always had Visualizations added like this in the initialization of the TagVisualizer: tagDef.Source = new Uri("something.xaml", UriKind.Relative);
But how can I ged rid of this cross-hair?
I cannot find anything about it.
By the way, it looks like this: http://img80.imageshack.us/img80/4728/crosshairc.png
http://img80.imageshack.us/img80/4728/crosshairc.png'/>
I've just run into the same problem because I didn't want a TagVisualization to display when I put a tag down (I wanted some items to be displayed in an already displayed librarystack). I solved it by setting the source of the ByteTagDefinition to null
ByteTagVisualizationDefinition tvBlue = new ByteTagVisualizationDefinition();
tvBlue.Value = 02;
tvBlue.Source = null;
MainTagVisualizer.Definitions.Add(tvBlue);
This gets rid of the crosshair - and I assume will work for IdentityTags, although I have not tried.
the crosshairs are used as the default visualization if you dont specify a custom source. we did this in order to let developers get the layout & configuration working without having to first define the visualization. a crosshair was selected as a default visual because it can be helpful in validating your physical offset properties
-robert (former PM for the Surface controls)

Resources