2012-04-09 6 views

Antwort

1

versuchen, den folgenden Code Bitte beachten Sie, dass

dies ist die Arbeit auf Gerät nur Test auf Emulator

import java.util.Enumeration; 

import net.rim.device.api.system.ApplicationDescriptor; 
import net.rim.device.api.system.CodeModuleGroup; 
import net.rim.device.api.system.CodeModuleGroupManager; 
import net.rim.device.api.ui.Field; 
import net.rim.device.api.ui.UiApplication; 
import net.rim.device.api.ui.component.LabelField; 
import net.rim.device.api.ui.container.MainScreen; 

public class StartUp extends UiApplication{ 
    public static void main(String[] args) { 
     StartUp up=new StartUp(); 
     up.enterEventDispatcher(); 
    } 
    public StartUp() 
    { 
     MainScreen screen=new MainScreen(); 
     CodeModuleGroup cmg = null; 
      CodeModuleGroup[] allGroups = CodeModuleGroupManager.loadAll(); 
      String moduleName = ApplicationDescriptor.currentApplicationDescriptor().getModuleName(); 
      for (int i = 0; i < allGroups.length; i++) { 
       if (allGroups[i].containsModule(moduleName)) { 
        cmg = allGroups[i]; 
        break; 
       } 
      } 
      if (cmg == null) { 
       screen.add(new LabelField("not able to fetch properties")); 
      } else { 
       double size=0; 
       for (Enumeration e = cmg.getPropertyNames(); e 
         .hasMoreElements();) { 
        String name = (String) e.nextElement(); 
        String value = cmg.getProperty(name); 
        System.out.println(name+" : "+value); 
        screen.add(new LabelField(name+" : "+value,Field.FOCUSABLE)); 
       } 
      } 
     UiApplication.getUiApplication().pushScreen(screen); 

    } 

} 
+0

mich fragen lassen weiß, ob es funktioniert oder nicht? –

+0

cmg gibt immer null zurück, so dass die Eigenschaften nicht abgerufen werden können – 1001

+0

haben Sie auf dem Gerät oder Simulator getestet? Sie sollten nur auf dem Gerät testen –