我一直在研究一個小應用程序,它的這一部分已經讓我難堪了。我有一個listField
(如屏幕截圖中的按鈕上方所示),某些按鈕以及此頁面上的一些靜態editFields
,並且我在滾動時遇到問題。自定義列表字段
我希望listField
被限制爲顯示5行(它在屏幕截圖中顯示2),並且如果listField中有5個以上的項目,可以滾動瀏覽它們(不滾動整個頁面,只是列表視圖)。
我也有另外一個問題與editFields,如果他們變得過大,由於大量的文字,他們將消失在屏幕上,因爲我的屏幕不會在未向super(Manager.NO_VERTICAL_SCROLL);
一個呼叫時,顯然需要對listField
運行的工作。
解決此問題的唯一方法是實現完整的自定義類listField
?還是有更簡單的選擇?
(截圖上imgur,因爲我沒有足夠的代表,發佈圖片) http://imgur.com/RcfspQP
感謝,奎因
編輯:
public class TestScreen extends MainScreen{
public TestScreen(){
//Without this call to super (which turns off vertical scrolling) the program throws an IllegalStateException and won't open the screen
super(Manager.NO_VERTICAL_SCROLL);
//Create some managers to organize the different Fields
VerticalFieldManager verticalAllManager = new VerticalFieldManager();
VerticalFieldManager verticalInfoManager = new VerticalFieldManager();
//Going to use this to limit the number of rows the list will display
VerticalFieldManager verticalListManager = new VerticalFieldManager()
{
protected void sublayout(int width, int height) {
//Just test numbers
super.sublayout(width, 100);
}
};
HorizontalFieldManager horizontalButtonManager = new HorizontalFieldManager();
//Add a title bar
add(new LabelField("Choose the call you want to view", LabelField.FIELD_HCENTER));
add(new SeparatorField());
//Creates the SimpleList ListField
Manager mainManager = getMainManager();
final SimpleList listField = new SimpleList(mainManager);
//Add items to the listField
listField.add("Time: 12:30 | Date: 3:10:2014");
listField.add("Time: 03:13 | Date: 1:25:2013");
//Creates a button to use for selecting the desired call
final ButtonField selectCall = new ButtonField("Select Call", ButtonField.CONSUME_CLICK);
//Creates fields for all the required information (blank to start)
final BasicEditField timeField, dateField, numberField, nameField;
timeField = new BasicEditField("Call Time: ", "");
dateField = new BasicEditField("Call Date: ", "");
numberField = new BasicEditField("Call Number: ", "");
nameField = new BasicEditField("Caller Name: ", "");
//Creates a button that can be used to save changes
final ButtonField saveChanges = new ButtonField("Save Changes", ButtonField.CONSUME_CLICK);
final ButtonField deleteRow = new ButtonField("Delete Call", ButtonField.CONSUME_CLICK);
//Adds all the info fields into a vertical manager to organize them
verticalInfoManager.add(timeField);
verticalInfoManager.add(dateField);
verticalInfoManager.add(numberField);
verticalInfoManager.add(nameField);
//Adds the 3 buttons to a horizontal manager to lay them out in a row
horizontalButtonManager.add(selectCall);
horizontalButtonManager.add(saveChanges);
horizontalButtonManager.add(deleteRow);
//Add the horizontal button manager to the vertical page manager
verticalAllManager.add(horizontalButtonManager);
//Add the vertical info manager to the vertical page manager
verticalAllManager.add(verticalInfoManager);
//Add all the managers, under the page manager, to the page
add(verticalAllManager);
}
}
這裏是我添加的示例頁面,以及它的另一個截圖ooks運行時:
現在最大的問題是,使用NO_VERTICAL_SCROLL調用super()會關閉整個頁面的滾動。沒有這個調用,信息字段會滾動,我只是(我認爲是)需要將verticalListManager和horizontalButtonManager添加到橫幅以防止它們滾動。
全部修好!我用你在#1說着,改變了清單上是一個經常ListField,這一切都工作正常。關於UI不是非觸摸屏的工作,有什麼我工作是在公司內部使用,都已經觸摸屏手機的客戶,使非觸摸屏不是問題。我將在以後的版本中加入了更多的功能,但是這是目前正在所需的全部。再一次,非常感謝你的幫助! – Br0k3nL1m1ts