我有一个包含组件列表的屏幕。当我向下滚动屏幕时,从按钮转到下一个屏幕(比如第20个组件)并返回上一个屏幕,返回btn,前一个屏幕(带有组件列表)显示第一个组件。如何在支持时显示带有第20个组件的屏幕?
观看视频here
Container mainContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
mainContainer.setScrollableY(true);
for (Map<String, Object> entrySet : protectedPlantsList) {
String title = entrySet.get("title").toString();
String sname = entrySet.get("sname").toString();
String nname = entrySet.get("nname").toString();
Label plantSpeciesLabel = new Label(title);
TextArea family = new TextArea(sname);
TextArea nepaliName = new TextArea(nname);
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Button infoIcon1 = new Button("", "TextField");
infoIcon1.addActionListener(e -> {
new ThreatCategory(res, threatData1.getName(), infoIcon1.getName(), threatList).show();
});
mainContainer.add(BorderLayout.centerEastWest(plantSpeciesLabel, ...., .....));
}
更新1 :
ProtectedPlantAndSpecies类:
Container mainContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
mainContainer.setScrollableY(true);
for (Map<String, Object> entrySet : protectedPlantsList) {
String title = entrySet.get("title").toString();
String sname = entrySet.get("sname").toString();
String nname = entrySet.get("nname").toString();
Label plantSpeciesLabel = new Label(title);
TextArea family = new TextArea(sname);
TextArea nepaliName = new TextArea(nname);
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Button infoIcon1 = new Button("", "TextField");
infoIcon1.addActionListener(e -> {
Form myDestinationForm = new ThreatCategory(res, cat, cat_description, threatList);
myDestinationForm.addShowListener(f -> infoIcon1.requestFocus());
myDestinationForm.show();
});
mainContainer.add(BorderLayout.centerEastWest(plantSpeciesLabel, ...., .....));
}
ThreatCategory类:
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
Command backCommand = new Command("Back", backFontImage) {
@Override
public void actionPerformed(ActionEvent evt) {
new ProtectedPlantAndSpecies(res, true).show();
}
};
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
答案 0 :(得分:0)
做这样的事情:
Form hi = new Form("Last", BoxLayout.y());
Button t = new Button("Next");
hi.add(t);
t.addActionListener(e -> {
Form f = new Form("Showing Last", BoxLayout.y());
for(int iter = 0 ; iter < 20 ; iter++) {
f.add(new Button("Button " + iter));
}
Button last = new Button("Last");
f.add(last);
f.addShowListener(ee -> last.requestFocus());
f.show();
});