0
我正在使用Titanium Appcelerator,我一直在想如何在應用程序中創建一個部分,用戶可以通過檢查多個複選框來存儲設置。任何幫助表示讚賞。如何使用Titanium Appcelerator在應用程序中創建複選框首選項區域?
我正在使用Titanium Appcelerator,我一直在想如何在應用程序中創建一個部分,用戶可以通過檢查多個複選框來存儲設置。任何幫助表示讚賞。如何使用Titanium Appcelerator在應用程序中創建複選框首選項區域?
for iphone or android?
/* store sections in here */
var mySections = [];
/* create section */
var mySection[0] = Ti.UI.createTableViewSection({
headerTitle:"first section"
})
/* tableview row to store checkbox */
var tableviewrow0 = Ti.UI.createTableViewRow();
/* if you don't want to build your own UI element you need
* to use the provided elements. checkboxes aren't standard
* ui elements, so you need to use switcher
*/
var switcher0 = Ti.UI.createSwitcher({
value: true, // or false
right: 10 // place it onto right side
});
tableviewrow0.add(switcher0);
/* label */
var label0 = Ti.UI.createLabel({
value:"option one",
textAlign:"left",
left:10
});
tableviewrow0.add(label0);
/* add row to section*/
mySection[0].add(tableviewrow0);
/* tableview */
var tbv = Ti.UI.createTableView({
data:mySection
});
win.add(tbv);
您需要繼續下一行和部分。我沒有編譯它,所以要小心;這只是一個想法。對於android有特殊的喜好;請查看kitchensink。
你說的對android有特殊偏好。我在我的res文件夾下創建了一個preferences.xml。問題是我找不到方法來檢查複選框的狀態是選中還是未選中。 – jan
您需要檢查checkbox.value值。最好的辦法是在變化事件中作出反應。 checked表示checkbox.value = true。 – mkind
你的意思是我必須檢查android:key =「checkbox」/>? – jan