2011-11-08 13 views
1

こんにちは私は黒いサンプルからペインマネージャのサンプルコードを入手しましたが、サンプルを実行してタブをダブルクリックするとメニューが表示されます。それがなぜ起こっているのか教えてください。私はあなたがコンテキストメニュー(ポップアップメニュー)を非表示にする場合code.Pleaseはちょうどこれは完全である私のために良い作品にこのコードメニューがペインのダブルクリックに来る理由、そのメニューが表示されないようにするには

protected boolean navigationClick(int status, int time) 
    { 
     return true; 
    } 

を書く

public class PaneManagerDemo extends UiApplication 
{ 
/** 
* Entry point for the application 
* @param args Command line arguments (not used) 
*/ 
public static void main(String[] args) 
{ 
    UiApplication app = new PaneManagerDemo(); 
    app.enterEventDispatcher(); 
} 


/** 
* Creates a new PaneManagerDemo object 
*/ 
public PaneManagerDemo() 
{  
    invokeLater(new Runnable() 
    { 
     public void run() 
     { 
      int headerType = 0; 
      // Display a dialog for user to select header type 
      OptionDialog dialog = new OptionDialog(); 
      int result = dialog.doModal(); 
      if(result == Dialog.OK) 
      { 
       headerType = dialog.getHeaderType(); 
      } 
      else if(result == Dialog.CANCEL) 
      { 
       System.exit(0); 
      } 
      //PaneScreen screen = new PaneScreen(headerType); 
      PaneScreen screen = new PaneScreen(headerType); 
      pushScreen(screen); 
     } 
    });   
} 


/** 
* A dialog popup used to choose a header type 
*/ 
private static class OptionDialog extends Dialog 
{   
    public static final int SCROLL_HEADER_TYPE = 0; 
    public static final int TAB_HEADER_TYPE = 1; 

    private ObjectChoiceField _choiceField;  

    /** 
    * Create a new HeaderDialog object 
    */ 
    public OptionDialog() 
    { 
     super(Dialog.D_OK_CANCEL, "Choose Header Type", Dialog.OK, null, Dialog.GLOBAL_STATUS); 
     _choiceField = new ObjectChoiceField("", new String[]{"Scrollable", "Tab"}, 0); 
     add(_choiceField);    
     _choiceField.setFocus(); 
    } 


    /** 
    * Returns an integer representing the header type 
    * 
    * @return SCROLL_HEADER_TYPE if scrollable header selected, TAB_HEADER_TYPE if tab header selected 
    */ 
    public int getHeaderType() 
    { 
     return _choiceField.getSelectedIndex(); 
    } 
} 


/** 
* Main screen for the application. Displays three panes 
* switchable via horizontal scroll field or tabs, depending 
* on user selection. 
*/ 
private final static class PaneScreen extends MainScreen 
{ 
    /** 
    * Creates a new PaneScreen object 
    * @param headerType The header type for the PaneManager, scrollable or tab style 
    */ 
    public PaneScreen(int headerType)   
    { 
     super(Field.FOCUSABLE);      

     // Instantiate the model for the pane manager and enable looping 
     PaneManagerModel model = new PaneManagerModel(); 
     model.enableLooping(true); 

     // Create a pane 
     VerticalFieldManager vfm = new VerticalFieldManager(); 
     vfm.add(new LabelField("Data 1"));    
     XYEdges edgesOne = new XYEdges(1, 1, 1, 1); 
     vfm.setBorder(BorderFactory.createRoundedBorder(edgesOne));     
     Pane pane = new Pane(new LabelField("Pane 1", Field.FOCUSABLE | Field.FIELD_HCENTER), vfm); 

     // Add the pane to the model 
     model.addPane(pane); 

     // Create a second pane 
     vfm = new VerticalFieldManager(); 
     for(int i = 0; i < 30; i++) 
     { 
      vfm.add(new LabelField("Data " + i, Field.FOCUSABLE)); 
     } 
     LabelField iconTextLabelField = new LabelField("Pane 2");    
     model.addPane(new Pane(iconTextLabelField, vfm)); 

     // Create a third pane    
     vfm = new VerticalFieldManager(); 
     ButtonField button = new ButtonField("Button", ButtonField.CONSUME_CLICK | ButtonField.NEVER_DIRTY); 
     button.setChangeListener(new FieldChangeListener() 
     { 
      public void fieldChanged(Field field, int context) 
      { 
       Dialog.inform("Button activated."); 
      } 
     }); 
     vfm.add(button); 
     model.addPane(new Pane(new LabelField("Pane 3"), vfm)); 

     // Choose which pane the model is displaying 
     model.setCurrentlySelectedIndex(1);      

     // Create the header and initialize the model and visual properties 
     TitleView header = null; 
     PaneManagerController controller = null;      
     if(headerType == OptionDialog.SCROLL_HEADER_TYPE) 
     { 
      header = new HorizontalScrollableTitleView(Field.FOCUSABLE); 
      controller = new HorizontalScrollableController(); 
     } 
     else if(headerType == OptionDialog.TAB_HEADER_TYPE) 
     { 
      header = new HorizontalTabTitleView(Field.FOCUSABLE);     
      ((HorizontalTabTitleView)header).setNumberOfDisplayedTabs(model.numberOfPanes()); 
      controller = new HorizontalTabController(); 
     } 
     else 
     { 
      throw new IllegalStateException("Header type is not valid."); 
     } 

     header.setModel(model); 
     XYEdges edgesFour = new XYEdges(4, 4, 4, 4); 
     header.setBorder(BorderFactory.createRoundedBorder(edgesFour)); 

     // Set arrow images 
     Bitmap leftArrow = Bitmap.getBitmapResource("leftArrow.png"); 
     Bitmap rightArrow = Bitmap.getBitmapResource("rightArrow.png");    
     if(leftArrow != null) 
     { 
      header.setLeftArrow(leftArrow); 
     } 
     if(rightArrow != null) 
     { 
      header.setRightArrow(rightArrow); 
     }   

     // Create the PaneView object, which will display the panes and is 
     // controlled by the model. 
     PaneView paneView = new PaneView(Field.FOCUSABLE);    
     paneView.setBorder(BorderFactory.createSimpleBorder(edgesOne)); 
     paneView.setModel(model); 

     // Initialize the PaneManagerView 
     PaneManagerView view = new PaneManagerView(Field.FOCUSABLE, header, paneView); 
     view.setModel(model);    
     view.setBorder(BorderFactory.createRoundedBorder(edgesFour)); 
     model.setView(view); 

     // Initialize the Controller 
     controller.setModel(model); 
     controller.setView(view); 
     model.setController(controller); 
     view.setController(controller); 

     add(view); 
    } 
} 
} 
+0

コードを入れてください。 –

+0

いいえ。 このコードは何を実行するのですか? –

+0

タブを作成します。残りの部分にいくつかのデータが表示されますが、そのタブをダブルクリックするとすべてのメニューが表示されます。 – iWatch

答えて

0

を助けて理解していないのです。

関連する問題