2013-01-23 155 views
-1

我在創建後退按鈕時遇到了一些問題。現在在窗體中有列表,我需要創建按鈕,它位於右下角的這個窗體中,當滾動列表時,按鈕保留在它的位置(右下角)。 我正在嘗試在屏幕較低處創建容器並進行隱形操作。但它沒有幫助,因爲列表沒有出現在容器下。如何在JAVA ME上創建後退按鈕,LWUIT

回答

0

您需要在Object Command中使用。

Command cmd = new Command(searchText) { 
     public void actionPerformed(ActionEvent evt) { 
      //TODO - implement back 
     } 
    }; 

,比加入他組建

f.addCommand(command); 
+0

如果我使用命令我得到一個完整的字符串我的按鈕,但我需要有隻有一個按鈕。如何使命令行不可見? – Dima

+0

如果你使用諾基亞,你不能這樣做,因爲這個軟鍵是最小的兩個軟鍵(儘管其中一個不是活動的) – neb1

+0

是否有其他方法可以解決這個問題?我只需要一個按鈕 – Dima

1

你可以試試這個...

import com.sun.lwuit.Command; 
import com.sun.lwuit.Form; 
import com.sun.lwuit.Display; 
import com.sun.lwuit.events.ActionEvent; 
import com.sun.lwuit.events.ActionListener; 
public class FirstApp extends MIDlet implements ActionListener{ 

Form f; 
Command exitCommand; 
public FirstApp() 
{ 
    //display form 
    Display.init(this); 
    f = new Form("myForm"); 
    f.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); 
} 
public void pauseApp() 
{ 
} 
public void destroyApp(boolean unconditional) 
{ 
} 

public void commandAction(Command c, Displayable dis) 
{ 

} 

protected void startApp() throws MIDletStateChangeException 
{ 
    //add exit button 
     Command exitCommand; 
    exitCommand = new Command("EXIT") 
    { 
     public void actionPerformed(ActionEvent e) { 
      notifyDestroyed(); 
     } 
    }; 
    f.addCommand(exitCommand); 
    f.setBackCommand(exitCommand); 
} 
相關問題