BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-01-2007, 05:44 AM   #1
Meenal
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Default NullpointerException

Please Login to Remove!

I dont know where i am going wrong.
Code:
package com.rim.samples.device.LostnFound;

import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.system.Bitmap;

class Lost_n_Found_Entry extends MainScreen {    
    private static Bitmap   _bitmap ;
    UiApplication           _UiApp;
    MenuItem                _MeniItem;
    String                  _S_enable;
    public Lost_n_Found_Entry() {    
        _bitmap  = Bitmap.getBitmapResource("ob_splash.PNG");
        add(new BitmapField(_bitmap, Field.FIELD_HCENTER | Field.FIELD_VCENTER));
        _UiApp   = UiApplication.getUiApplication();        
        if(Lost_n_Found_Passwd._s_Enable_Flag == 0)
            _S_enable = "Enable";
        else
            _S_enable = "Disable";
    }   
    
    MenuItem _Enable = new MenuItem(_S_enable, 200000, 10) {
        public void run() {
            if(_S_enable.equals("Enable") ) {
                Lost_n_Found_Passwd._s_Enable_Flag = 1;
                _UiApp.popScreen(_UiApp.getActiveScreen());
                _UiApp.pushScreen(new Lost_n_Found_Entry());
            } else {
                Lost_n_Found_Passwd._s_Enable_Flag = 0;
                _UiApp.popScreen(_UiApp.getActiveScreen());
                _UiApp.pushScreen(new Lost_n_Found_Entry());
            }
        }
    };
    MenuItem _Settings = new MenuItem("Settings", 200000, 10) {
        public void run() {
            _UiApp.popScreen(_UiApp.getActiveScreen());
            _UiApp.pushScreen(new Lost_n_Found_Settings());
        }
    };
    MenuItem _About = new MenuItem("About", 200000, 10) {
        public void run() {            
        }
    };
    MenuItem _Exit = new MenuItem("Exit", 200000, 10) {
        public void run() {
            System.exit(0);
        }
    }; 
    
    protected void makeMenu(Menu menu, int instance) {  
        menu.add(_Enable);
        menu.add(_Settings);
        menu.addSeparator();
        menu.add(_About);
        menu.addSeparator();
        menu.add(_Exit);    
        super.makeMenu(menu, instance);    
    }
}
When ever i click on the trackwheel to view the menu , i get a nullPointerException.
__________________
Thanks
Meenal
Offline  
Old 08-01-2007, 06:48 AM   #2
arifzaman
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Default

Hi Meenal,

Before overriding "protected void makeMenu(Menu menu, int instance)" function, you have to initialized all items or variables that you want to use here.

In your code you are going to add "MenuItem _Enable = new MenuItem(_S_enable, 200000, 10)" MenuItem, without initializing xxx8220;_S_enablexxx8221; variable. You have to initialize first to access this variable. You may declare this variable as the following or as your experience:

Code:
String _S_enable = "Enable";
Hope this will work!

Cheers!
ARIF
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Single To 3 Phase 7.5KW 10HP 220V Variable Frequency Drive Inverter CNC VFD VSD picture

Single To 3 Phase 7.5KW 10HP 220V Variable Frequency Drive Inverter CNC VFD VSD

$169.90



VEVOR 7.5KW 10HP Variable Frequency Drive Inverter Convert 1 To 3 Phase VFD 220V picture

VEVOR 7.5KW 10HP Variable Frequency Drive Inverter Convert 1 To 3 Phase VFD 220V

$163.99



LENZE E82EV751_4B INVERTER 0.75kW 0-400/500V USED DRIVE picture

LENZE E82EV751_4B INVERTER 0.75kW 0-400/500V USED DRIVE

$288.88



205A MMA ARC Welding Machine 110/220V Dual Volt IGBT Inverter Welder Machine picture

205A MMA ARC Welding Machine 110/220V Dual Volt IGBT Inverter Welder Machine

$118.99



TOOLIOM 135A 110V Stick Welder MMA ARC Welder Machine DC Inverter Welder picture

TOOLIOM 135A 110V Stick Welder MMA ARC Welder Machine DC Inverter Welder

$67.99



VFD 5.5KW 7.5HP 220V 3 Phase Variable Frequency Drive Inverter CNC picture

VFD 5.5KW 7.5HP 220V 3 Phase Variable Frequency Drive Inverter CNC

$173.95







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.