2010-11-08 8 views

Répondre

1

Vous voulez personnaliser l'écran pop-up comme celui-ci

public class CustomPopUpScreen extends PopupScreen { 
    public CustomPopUpScreen() { 
     super(new VerticalFieldManager(CustomPopUpScreen.NO_HORIZONTAL_SCROLL)); 
     add(new ButtonField()); 
     add(new ButtonField()); 
    } 
} 

Ce code vous aidera à

1

Ici, je crée l'objet de type PopupScreen et appeler la méthode givePopup:

PopupScreen popup1=givePopup(); 
PopupScreen givePopup(){ 
    VerticalFieldManager popvfm =new VerticalFieldManager(); 
    ButtonField ok=new ButtonField("ok"); 
    ButtonField cancel=new ButtonField("cancel"); 
    popvfm.add(ok); 
    popvfm.add(cancel); 
    PopupScreen popup=new PopupScreen(popvfm); 
    return popup; 
} 

Cette méthode renvoie une instance PopupScreen qui a un gestionnaire de champs vertical et j'ajoute deux champs de bouton sur ce gestionnaire.

1
public class FriendPopupScreen extends MainScreen{ 
    int dialogWidth; 
    int dialogHeight; 
    LabelField lblTitle; 

    HorizontalFieldManager hfmTitle; 

    Vector data; 

    public FriendPopupScreen() { 

     dialogWidth = 300; 
     dialogHeight = 150; 

     lblTitle = newLabelField("Choose option"); 

     hfmTitle = new HorizontalFieldManager(USE_ALL_WIDTH){ 

      protected void sublayout(int maxWidth, int maxHeight) { 
       // TODO Auto-generated method stub 
       maxWidth= Display.getWidth(); 
       maxHeight=40; 
       super.sublayout(maxWidth, maxHeight); 
       setExtent(maxWidth, maxHeight); 
      } 

      protected void paint(Graphics graphics) { 
       // TODO Auto-generated method stub 

       graphics.setBackgroundColor(Color.BLACK); 
       graphics.clear(); 
       super.paint(graphics); 
      } 

     }; 

     hfmTitle.add(lblTitle); 
     lblTitle.setMargin(10,0,0,10); 
     add(hfmTitle); 
    } 
    protected void sublayout(int width, int height) { 
      setExtent(dialogWidth, dialogHeight); 
      setPosition(Display.getWidth()/2-(dialogWidth/2), Display.getHeight()/2 - (dialogHeight/2)); 
      layoutDelegate(dialogWidth, dialogHeight); 
     } 
} 

et appeler ceci:

FriendPopupScreen popup = new FriendPopupScreen(); 
UiApplication.getUiApplication().pushModalScreen(popup); 
Questions connexes