Issue with displaying the radio button label in tianium? - titanium

I have created a radio button from the following link, https://github.com/yozef/TiRadioButtonGroup. I am able to see the radio buttons but the respective radio button labels are not showing. How can we display the radio button labels.
My code:
View:
<Alloy>
<Window class="container">
<View id="radiopicker" ></View>
</Window>
</Alloy>
Style:
".container": {
backgroundColor:"red",
layout: 'vertical'
}
"#radiopicker":
{
width: '90%',
top: '25dp'
}
Controller:
(function() {
var radioButton = require('/ui/tiRadioButton');
var radioGroup2 = radioButton.createGroup({
groupId:1,
width:20,
height:150,
layout:'vertical',
radioItemsValue:['One', 'Two', 'Three'],
radioItemsPadding:10,
radioItemsBackgroundSelectedImage:'/radioButtonActive.png',
radioItemsBackgroundImage:'/radioButton.png',
radioItemsWidth:33,
radioItemsHeight:34
});
var button = Ti.UI.createButton({
title:'Get value'
});
button.addEventListener('singletap', function(e) {
alert("Vertical radioGroup selectedIdx: " + radioGroup2.selectedValue);
});
$.radiopicker.add(radioGroup2);
$.radiopicker.add(button);
})();
$.index.open();
Screenshot:
The label option one, two and three are not displaying. Please help me out of this issue. I need to display the labels too.

I've gone ahead and updated my Module which will give you the result you want... You can fetch it here:
https://github.com/yozef/TiRadioButtonGroup

I think you should put some label near to the radioButtons by yourself. Have a look at my modified code. It is not tested but should do the trick. Maybe you have to play around with the width/height/left etc attributes a bit.
(function() {
var radioButton = require('/ui/tiRadioButton');
var radioGroup2 = radioButton.createGroup({
groupId:1,
width:20,
height:150,
layout:'vertical',
radioItemsValue:['One', 'Two', 'Three'],
radioItemsPadding:10,
radioItemsBackgroundSelectedImage:'/radioButtonActive.png',
radioItemsBackgroundImage:'/radioButton.png',
radioItemsWidth:33,
radioItemsHeight:34
});
//Create a view to hold your labels
var labelsView = Ti.UI.createView({
height:150,
left: "30" //Or whereever you want to place it
layout:'vertical'
});
//Create the labels
var label1 = Ti.UI.createLabel({
text: "One",
height: "34",
width: Titanium.UI.SIZE
});
var label2 = Ti.UI.createLabel({
text: "Two",
height: "34",
width: Titanium.UI.SIZE
});
var label3 = Ti.UI.createLabel({
text: "Three",
height: "34",
width: Titanium.UI.SIZE
});
//Attach the labels to your view and your view to your radioPicker view
labelsView.add(label1);
labelsView.add(label2);
labelsView.add(label3);
$.radiopicker.add(labelsView);
var button = Ti.UI.createButton({
title:'Get value'
});
button.addEventListener('singletap', function(e) {
alert("Vertical radioGroup selectedIdx: " + radioGroup2.selectedValue);
});
$.radiopicker.add(radioGroup2);
$.radiopicker.add(button);
})();
$.index.open();

I have gone through your code and found that your window background color is set to 'white' or '#ffffff' and in tiRadioButton.js module label color is also set to 'white' or '#ffffff'. Hence you are not able to see the lable.
You can change either the window backgroundColor or label color.
For change windowBackground color :
at abc.tss file
".container": {
backgroundColor:"red", // any color you want
layout: 'vertical'
}
For change Label color :
at tiRadioButton.js file
var radioItemLabel = Ti.UI.createLabel({
width:Ti.UI.SIZE,
height:Ti.UI.SIZE,
text: arg.radioItemsValue[i],
font: {}, // Can add your own font styles
color:'#FFFFFF', //Label color
top:isVertical?null:5, // 5 padding between RadioBtn & Label
left:!isVertical?null:5, // 5 padding between RadioBtn & Label
id:i,
});
//**In color field you can change the label color **

Related

TabContainer displays Tabs only at windowresize

I want to create a Tabcontainer and fill its TabPage contents programmatically, but the TabPages won't be displayed. So far my Code:
_buildUI: function () {
var bordercontainer = new dj_BorderContainer({ style: "height: 100%; width: 100%;", gutters: false, region: "top" });
var tabcontainer = new dj_TabContainer({ useMenu: false, region: "center", tabposition: "top", doLayout: "false", style: "height: 100%; width: 100%;" });
for (var i = 0; i < ki_KisConfig.widgets.movingwindow.calccount; i++) {
var contentpane = new dj_ContentPane({ title: "Calculation " + (i + 1), content: "content", style: "height: 100%; width: 100%;" });
//contentpane.startup();
tabcontainer.addChild(contentpane);
}
tabcontainer.startup();
bordercontainer.addChild(tabcontainer);
bordercontainer.startup();
do_domConstruct.place(bordercontainer.domNode, this.interface, "first");
bordercontainer.resize({ h: "265px", w: "432px" });
},
I've googled around and tried different things. As you cann see I'm setting the doLayout-Property mentioned here. I also use a BorderContainer like mentioned here in the last posting and I'm trying to resize it after creating the TabContainer like mentioned here.
It doens't matter if I'm calling the method in the postCreate- or the startup-function of the containing widget.
I'm trying to set the width and height via style or to startup every "sub"widget.
Nothing works and the TabContainer only gets displayed when I'm resizing the browserwindow or resizing it by opening/closing the developertools (F12). If it gets displayed it looks like I want it. The only problem is that the TabList has a size of 0x0 and the same with the TabPaneWrapper when I'm inspecting directly the DOM.
Has anyone any idea?
Edit
After calling startup only on the BorderContainer I get this result:
The tablist layout is strange and also the content of the programmatic selected tab isn't displayed. Everything is again fine after a window resize:
Solution (summary)
I retrieved the best result with defining the BorderContainer and the TabContainer in the HTML-template. Unfortunately the layout of the tablist still failed. This answer delivered the solution for correct tablist layout: My widget didn't contain resize() so I added it and everything is now working fine.
resize: function() {
var tabcontainer = dj_registry.byId("tabContainerMW");
if (tabcontainer) {
tabcontainer.resize(arguments);
}
},
Some notes to your code:
The region attribute is here not required. Its only used to indicate the position for BorderContainer children.
var bordercontainer = new dj_BorderContainer({
style: "height: 100%; width: 100%;",
gutters: false,
region: "top"
});
You don't need to set a width and height on your ContentPane, let this do the TabContainer.
var contentpane = new dj_ContentPane({
title: "Calculation " + (i + 1),
content: "content",
style: "height: 100%; width: 100%;"
});
I've created a sample for you, maybe this helps you out.
require(["dijit/layout/BorderContainer", "dijit/layout/TabContainer",
"dijit/layout/ContentPane", "dojo/domReady!"],
function(BorderContainer, TabContainer, ContentPane) {
// first create the BorderContainer without any arguments.
let bc = new BorderContainer({}, "bc");
// then create your TabContainer with region center.
let tc = new TabContainer({
region: 'center'
}, document.createElement("div"));
// add it to your BorderContainer
bc.addChild(tc);
// then create three tab panes (ContentPane) and add them to your TabContainer
let cp = new ContentPane({
content: "My tab pane!",
title: "My tab title"
}, document.createElement("div"));
tc.addChild(cp);
let cp2 = new ContentPane({
content: "My second tab pane!",
title: "My second tab title"
}, document.createElement("div"));
tc.addChild(cp2);
let cp3 = new ContentPane({
content: "My closable tab pane!",
title: "My closable tab title",
closable: true
}, document.createElement("div"));
tc.addChild(cp3);
// call startup on your BorderContainer. startup of BorderContainer will call also the startup methods of all children (TabContainer, ContentPane's).
bc.startup();
});
body, html {
height: 100%;
width: 100%;
overflow: hidden;
margin: 0 auto;
}
<link href="//ajax.googleapis.com/ajax/libs/dojo/1.4/dijit/themes/tundra/tundra.css" rel="stylesheet"/>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<span class="tundra" style="width: 100%; height: 100%;">
<div id="bc" style="width: 100%; height: 100%;"></div>
</span>
Edit
As an addition:
I was able to create a fiddle, which reproduces the failure. The problem here is that the createDialogContent() method is getting called after the dialog show's up. As I mentioned below in the comments section, it is important to create a dialog's content before showing it.
In this fiddle (bottom end of code) are two sections, which call both the same methods, just transposed. In the first snippet, the methods are called in the wrong order. Int the second snippet, they're called in the right order.
// uncomment this
createDialogContent();
dialog.show();
// comment this
// dialog.show();
// createDialogContent();

Titanium: Unable to access dynamically added TextInput's value on click of a button

index.xml
<Alloy>
<Window class="container">
</Window>
</Alloy>
index.js
function btnClickedHandler(e){
alert(nameTi.text);
alert($.index.nameTi);
}
function addContent(){
var showBtn = Ti.UI.createButton({
id: "showButton",
title:"Show Text",
top: 10,
});
var nameTi = Ti.UI.createTextField({
id:"displayText",
textFieldId: 'displayText',
width: 50
});
showBtn.addEventListener("click", btnClickedHandler);
$.index.add(nameTi);
$.index.add(showBtn);
}
$.index.open();
addContent();
Any suggestions to access dynamically added text input. One way could be definitely by storing instance in global variable. But can be done using id like $("#instanceId")
Try this:
function addContent(){
var showBtn = Ti.UI.createButton({
id: "showButton",
title:"Show Text",
top: 10,
});
var nameTi = Ti.UI.createTextField({
id:"displayText",
textFieldId: 'displayText',
width: 50
});
showBtn.addEventListener("click", function(){
alert(nameTi.text);
alert($.index.nameTi);
}
});
$.index.add(nameTi);
$.index.add(showBtn);
}
$.index.open();
addContent();

Titanium Scrollable view is jerky, momentarily stops half way

I have been trying to figure out why a scrollable view in my app is very jerky, it momentarily stops half way when I swip between pages. The contents of each page is not complex, just a few text fields and an image. The number of pages is up to 8.
The versions I use are; Titanium 3.1.2GA Alloy 1.2.1 iOS 6.1.3 on an iPhone4 <<< Important - the jerkyness is not that visible on the iPhone5
Please note that I started this project in November last year and have along the way upgraded my enviroment when new releases have become available. Could there be some old code being used? I saw an early pre-1.0 Alloy bug raised for this issue, could it still be there in my environment?
I created a test app using the standard two tab Alloy template and added the code below. For the second tab I had just saved to the disk the image used in tab 1. Tab 3 did not have any images but was still a bit jerky. In my app I have a few more views on each page and it is very jerky.
If anyone have any suggestions I would really appreciate it. It would be great if someone please confirm the issue with an iPhone4, just to have make sure my environment is not the cause (I guess i could try to uninstall and reinstall but I am not sure how to properly uninstall everything).
Cheers, Lars
Index.xml
<Alloy>
<TabGroup>
<Tab title="Tab 1" icon="KS_nav_ui.png">
<Window id="window1" title="Tab 1">
</Window>
</Tab>
<Tab title="Tab 2" icon="KS_nav_views.png">
<Window id="window2" title="Tab 2">
</Window>
</Tab>
<Tab title="Tab 3" icon="KS_nav_ui.png">
<Window id="window3" title="Tab 3">
</Window>
</Tab>
</TabGroup>
Index.js
function createViews() {
var v10 = createPage('http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/402px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg', "#00FFFF");
var v11 = createPage('http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/402px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg', "#FF00FF");
var v12 = createPage('http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/402px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg', "#FFFF00");
var v13 = createPage('http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/402px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg', "#FFFFFF");
var v14 = createPage('http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/402px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg', "#FFFFFF");
var v15 = createPage('http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/402px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg', "#FFFFFF");
var v20 = createPage("images/Mona_Lisa.jpg", "#00FFFF");
var v21 = createPage("images/Mona_Lisa.jpg", "#FF00FF");
var v22 = createPage("images/Mona_Lisa.jpg", "#FFFF00");
var v23 = createPage("images/Mona_Lisa.jpg", "#FFFFFF");
var v24 = createPage("images/Mona_Lisa.jpg", "#FFFFFF");
var v25 = createPage("images/Mona_Lisa.jpg", "#FFFFFF");
var v30 = createPage(null, "#229900");
var v31 = createPage(null, "#333333");
var v32 = createPage(null, "#009900");
var v33 = createPage(null, "#FF77FF");
var v34 = createPage(null, "#007744");
var v35 = createPage(null, "#009988");
var v36 = createPage(null, "#DDBB00");
var v37 = createPage(null, "#CCCCCC");
var v38 = createPage(null, "#99FFFF");
var photosView1 = Ti.UI.createScrollableView({
views:[
v10,v11,v12,v13,v14,v15 // http images
],
showPagingControl:true,
cacheSize: 21
});
$.window1.add(photosView1);
var photosView2 = Ti.UI.createScrollableView({
views:[
v20,v21,v22,v23,v24,v25 // file images
],
showPagingControl:true,
cacheSize: 21
});
$.window2.add(photosView2);
var photosView3 = Ti.UI.createScrollableView({
views:[
v30,v31,v32,v33,v34,v35 // colored pages
],
showPagingControl:true,
cacheSize: 21
});
$.window3.add(photosView3);
}
function createPage(image, bkgColor) {
var detailsView = Ti.UI.createView({
width: Ti.UI.FILL,
height: Ti.UI.FILL,
top: 5,
left: 5,
right: 5,
bottom: 100,
backgroundColor: bkgColor
});
if (image) {
var imageView = Ti.UI.createImageView({
image:image
});
detailsView.add(imageView);
}
var labelView0 = Ti.UI.createLabel({
text: "Label 0"
});
detailsView.add(labelView0);
var pageView = Ti.UI.createView({
width: Ti.UI.FILL,
height: Ti.UI.FILL,
backgroundColor: "#E4E8E8"
});
pageView.add(detailsView);
var labelContainer = Ti.UI.createView({
height: 90,
bottom: 5,
left: 5,
right: 5,
backgroundColor: "#FFAAFF"
});
pageView.add(labelContainer);
var labelView1 = Ti.UI.createLabel({
bottom: 50,
text: "Label 1"
});
labelContainer.add(labelView1);
var labelView2 = Ti.UI.createLabel({
bottom: 10,
text: "Label 2"
});
labelContainer.add(labelView2);
return pageView;
}
createViews();
$.index.open();
6 Sep 2013 ...
Based on a comment that ambiguity of the layouts could cause the jerkyness I have now tried with views that have absolute positions and sizes. I also used just images from the file system that had the exact size as the image view. Please see code below. It is better but the jerkyness is still there which means that the underlaying issue is not resolved by absolute positions and sizes.
function createPage(image, bkgColor) {
var detailsView = Ti.UI.createView({
width: 300,
height: 300,
top: 0,
backgroundColor: bkgColor
});
if (image) {
var imageView = Ti.UI.createImageView({
width: 300,
height: 300,
image:image
});
detailsView.add(imageView);
}
else {
var labelView0 = Ti.UI.createLabel({
width: 300,
height: 300,
text: "No Image"
});
detailsView.add(labelView0);
}
var pageView = Ti.UI.createView({
width: 300,
height: 400,
backgroundColor: "#E4E8E8"
});
pageView.add(detailsView);
var labelContainer = Ti.UI.createView({
width: 300,
height: 100,
top: 300,
backgroundColor: "#FFAAFF"
});
pageView.add(labelContainer);
var labelView1 = Ti.UI.createLabel({
width: 300,
height: 20,
top: 10,
left: 10,
text: "Label 1"
});
labelContainer.add(labelView1);
var labelView2 = Ti.UI.createLabel({
width: 300,
height: 20,
top: 40,
left: 10,
text: "Label 2"
});
labelContainer.add(labelView2);
return pageView;
}
For me, it had to do with the scrollableView.cacheSize property. Try setting it to the length of your views array.

How to set the column layout in ext4.1

I have a problem with EXTJS 4.1 layout.
how to set the column layout for a panel in ext 4.1.
In mozilla its working fine.
But in IE, it was not rendering and moreover, IE is trying to close.
the sample code is,
var panel1 = getPanel1();
var panel2 = getPanel2();
var panel3 = Ext.create('Ext.Panel',{
layout:{type:'table',columns:2},
title:'Panel3',
items:[panel1,panel2],
renderTo:Ext.getBody()
});
Please give me a solution to render the panels in columns in ext4.1 ....
A way that I know works because I do it in my code is to use a hbox layout. I believe this is an equivalent layout for your example:
var panel1 = getPanel1();//make sure this panel contains flex: .5
var panel2 = getPanel2();//make sure this panel contains flex: .5
var panel3 = Ext.create('Ext.Panel',{
layout:{type:'hbox'},
title:'Panel3',
items:[panel1,panel2],
renderTo:Ext.getBody()
});
Have you tried the example that they show in the documentation?
Ext.create('Ext.panel.Panel', {
title: 'Column Layout',
width: 350,
height: 250,
layout:'column',
items: [{
title: 'Column 1',
columnWidth: 0.50
},{
title: 'Column 2',
columnWidth: 0.50
}],
renderTo: Ext.getBody()
});

Titanium Appcelerator: Views with buttons on Android become inactive after 1st instance

I have a win1 and it has a button to close it.
Also I have a button to create a view1.
view1 has a button to hide it.
When I click the hide button on the view1, the button on the win1 which supposed to create the view1 when clicked, becomes disabled. Why is it? It is only a problem in Android. Please help. Thank you.
var win1 = Titanium.UI.currentWindow;
var closeButton = Titanium.UI.createButton({
image:'images/icontest.png',
backgroundImage: 'none',
top:0,
right:0
});
closeButton.addEventListener('click',function()
{
win1.close({transition:Ti.UI.iPhone.AnimationStyle.CURL_DOWN});
});
win1.add(closeButton);
//Main view & button
var view1=Ti.UI.createView({
backgroundColor: '#fff',
borderColor: '#888',
borderWidth: 4,
height: 172,
width: 275,
top:50,
opacity: 0.75,
borderRadius: 8
});
var closeButton2 = Titanium.UI.createButton({
image:'images/icontest.png',
backgroundImage: 'none',
top:0,
right:0
});
closeButton2.addEventListener('click',function()
{
view1.hide();
});
view1.add(closeButton2);
var OpenButton = Titanium.UI.createButton({
image:'images/icontest.png',
backgroundImage: 'none',
top:100,
right:50
});
OpenButton.addEventListener('click',function()
{
win1.add(view1);
});
win1.add(OpenButton);
You are adding view1 every time OpenButton is clicked. Actually you want to show view1 when OpenButton is clicked. So what you should do is:
OpenButton.addEventListener('click',function()
{
view1.show();
});
and view1 should be added outside of OpenButton.addEventListener. Like this:
win1.add(OpenButton);
win1.add(view1);