我一直在研究一个小应用程序,它的这一部分已经让我难堪了。我有一个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