1
リストアイテムを中央に整列させる際に問題があります。 plzは私を助けます。ここで私がしたコードです。LWUITを使用してリストを中央に揃える方法
import com.sun.lwuit.Command;
import com.sun.lwuit.Component;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Image;
import com.sun.lwuit.Label;
import com.sun.lwuit.List;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;
import javax.microedition.midlet.MIDlet;
/**
* @author Administrator
*/
public class main extends MIDlet implements ActionListener
{
private Image logo;
private Label logoLabel;
private List menu;
private Command select,exit;
public void startApp() {
Display.init(this);
Form form1 =new Form();
form1.getStyle().setBgColor(0xe5a812);
try{
logo=Image.createImage("/sid_logo.png");
}
catch(Exception e){
System.out.println("::::::"+e);
}
logoLabel=new Label(logo);
select=new Command("Select");
exit=new Command("Exit");
//form1.setLayout(new BorderLayout());
//form1.addComponent(BorderLayout.NORTH,logoLabel);
BoxLayout boxlayout=new BoxLayout(BoxLayout.Y_AXIS);
form1.setLayout(boxlayout);
form1.addComponent(logoLabel);
logoLabel.setAlignment(Component.CENTER);
logoLabel.getStyle().setBgColor(0xe5a812);
menu=new List();
menu.addItem("LIST 1");
menu.addItem("LIST 2");
form1.addComponent(menu);
form1.addCommand(select);
form1.addCommand(exit);
form1.setCommandListener(this);
form1.show();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void actionPerformed(ActionEvent event){
//int index=menu.getSelectedIndex();
if(event.getCommand()==select && menu.getSelectedIndex()==0){
System.out.println("Check list1");
}
if(event.getCommand()==select && menu.getSelectedIndex()==1){
System.out.println("Check list 2");
}
if(event.getCommand()==exit){
notifyDestroyed();
}
}
}