Codename one Radio Buttons in a ButtonGroup - radio-button

#Shai According to the image below got from CleanMordern Project.
how can I style my radio buttons using CSS to look exactly as Shai did his,
and also make actions on each button to show different container when pressed
ButtonGroup barGroup = new ButtonGroup();
RadioButton all = RadioButton.createToggle("All", barGroup);
all.setUIID("SelectBar");
RadioButton featured = RadioButton.createToggle("Featured", barGroup);
featured.setUIID("SelectBar");
RadioButton popular = RadioButton.createToggle("Popular", barGroup);
popular.setUIID("SelectBar");
RadioButton myFavorite = RadioButton.createToggle("My Favorites", barGroup);
myFavorite.setUIID("SelectBar");
Label arrow = new Label(res.getImage("news-tab-down-arrow.png"), "Container");
add(LayeredLayout.encloseIn(
GridLayout.encloseIn(4, all, featured, popular, myFavorite),
FlowLayout.encloseBottom(arrow)
));

You can open the theme file in the designer tool and just copy the styling from there. I implemented this using image backgrounds to keep some pixels free for the arrow on the bottom.
If you look at the theme you will see I just placed a background image that's solid red on top and has a white bottom. Then I have a separate "arrow" image which is animated with the code to the selected button on every click. Everything else is just colors and fonts which is trivial.

Related

When the frame become too small, the buttons in a panel are hidden

I use a class that extends Frame and in the constructor after defining all the propriety of the new Frame i append with the BorderLayout.SOUTH a new Panel that contains some buttons.
When I reduce the size of the Frame, if the space for the buttons isn't enough some of these disappear from the Frame.
How can I fix this problem?
public AdventureUI(Tappa tappa){
setTitle("Adventure Game");
//DIMENSIONE STANDARD DELLA FINESTRA
setSize(700,500);
setMinimumSize(new Dimension(400,300));
pannelloPrincipale = new Panel(new BorderLayout());
pannelloBottoni = new Panel();
testoTappa = new TextArea(tappa.toString(),25,50,TextArea.SCROLLBARS_NONE);
testoTappa.setEditable(false);
testoTappa.setBackground(new Color(211,211,211));
areaUtente = new TextArea("",25,30,TextArea.SCROLLBARS_VERTICAL_ONLY);
//ADD BUTTONS TO PANEL
setBottoni(pannelloBottoni,tappa.getTappeCollegate());
//AGGIUNGIAMO ELEMENTI AL PANNELLO PRINCIPALE
pannelloPrincipale.add(testoTappa,BorderLayout.CENTER);
pannelloPrincipale.add(areaUtente,BorderLayout.EAST);
//AGGIUNGIAMO PANNELLI AL FRAME
add(pannelloPrincipale,BorderLayout.CENTER);
add(pannelloBottoni,BorderLayout.SOUTH);
// ASCOLTATORE FINESTRA
addWindowListener(new AdventureUIListener());
setVisible(true);
}
Images of the problem:
As you can see the button with 26 is hidden.
As you can see the button with 26 is hidden.
Yes that is because a FlowLayout always displays components at their preferred size. If there is not enough room then the component wraps to the next line, but unfortunately the height of the panel is not increased so you don't see the button.
Check out the Wrap Layout, it was designed to handle this situation. That is it will recalculate the height of the panel so all the buttons are displayed on multiple lines. At least it works with Swing. I've never test it with AWT because most people don't use AWT anymore.

Nested List "Back" button overlapping toolbar title?

I have created a nested list. When the text of the selected item is quite long than back button overlaps the toolbar title.
Is there any way to align toolbar text to right or set font size??
Any help is appreciated.
You can use only "Back" (or something else) for the back button. You just need to add this config in your nested list: useTitleAsBackText: false (It is true by default).
Else, you can reduce the font size for both button and toolbar title in your CSS file. Like this:
.my-nested-list .x-toolbar .x-button-label,
.my-nested-list .x-toolbar .x-title {
font-size: 13px;
}

Titanium: How to remove background of Search bar?

How can I remove the background of search bar ? I tried by changing background color but it also changes cancel button's color !!!
Thanks...
The best alternative to this is creating a custom search bar with Ti.UI.textField and Ti.UI.button. Add them both to a view and customize it as you please. Finally, just add an event listener to the button click, and voila!
Take a look at this Module: https://github.com/viezel/NappUI
It extends the properties for several UI Elements, including SearchBar, here is the list.
SearchField BackgroundImage
Custom Cancel button
barColor - background gradient of the button. (similar to navbar)
color - color of the button title
title - change the default Cancel text
font - set the font of the button
Appearance of the keyboard
Disable the search icon
To install it, I recommend you to use the new gitTio command line, this will automatically download the module, install it on the modules folder on Application Support folder and add the proper config line on tiapp.xml.
gittio install -g dk.napp.ui
And here is an example of a SearchBar using the new properties enabled by this Module
var searchBar = Ti.UI.createSearchBar({
searchFieldBackgroundImage:"searchbg.png",
showsScopeBar:true,
scopeButtonTitles:["hello", "yes"],
customCancel:{
barColor:"#333",
color:"#ddd",
title:"Hit me",
font:{
fontSize:16,
fontWeight:"bold",
fontFamily:"Georgia"
}
},
appearance:Titanium.UI.KEYBOARD_APPEARANCE_ALERT,
barColor:"transparent",
disableSearchIcon:true //disables the search icon in the left side
});
If you are talking about the gradient blue, I removed it on my app with:
var searchBox = Ti.UI.createSearchBar({
barColor: '#eee'
});
Hope this helps.
Unfortunately 'barColor' doesn't work. Ti seems to change the color by changing the opacity or hue or something. DannyM's workaround is the best.
I must have wasted a zillion hours making sense of Titanium's background colors, background images, bar colors and their active/inactive cousins.
Conclusion: "Free" software is costly if you count the time you waste on silly bugs and lack of useful documentation.

icon as an image

is it possible to use icon file as a image for a button in visual basic?
f.e.
I have 3 buttons that need to have 3 icons when you click the button the icon of the button needs to be the icon of the form is this posible?
btnIcon1 = my.resources.ICO1
btnIcon2 = my.resources.ICO2
The most basic method to do that:
myButton.Image = Me.Icon.ToBitmap
You can also use:
myButton.Image = My.Resources.myIcon.ToBitmap
Both of these methods extract and use the 32x32 icon from the .ico file.

making a thumbnail toolbar (windowsAPICodePack,windows 7) button invisible in vb.net

I'm trying to make a thumbnail toolbar button (TTB from now on)visible when the it is clicked. I know how to do stuff when it is clicked, AddHandler etc. But if I tell it TTB.visible=false then it doesn't become invisible. If I put TTB.enabled = False it will be disabled, so it's only the visible that isn't working.
Also I put a button on my form (not a TTB) and when that is click wrote, TTB.visible = false and that didn't work, so there is no way to make it invisible.
Try set TTB.visible=true after you Add it into toolbar button list.