BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 08-01-2007, 05:44 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
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


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

OEM DELL PA-6 Family AC Adapter 9364U A57
$5.99
OEM DELL  PA-6 Family AC Adapter 9364U    A57 pictureGenuine OEM Dell L240AS-00 240W 0T5VF6 Power Supply
$34.99
Genuine OEM Dell L240AS-00 240W 0T5VF6 Power Supply pictureGENUINE OEM FACTORY SEALED DELL 5130cdn/C5765dn BLACK IMAGING DRUM
$49.95
GENUINE OEM FACTORY SEALED DELL 5130cdn/C5765dn BLACK IMAGING DRUM  pictureDELL 725-10263 / 331-1310 / KT74N Lamp manufactured by DELL
$216.18
DELL 725-10263 / 331-1310 / KT74N Lamp manufactured by DELL pictureFor Dell Inspiron Mini 10 Series OEM 1.33GHz CPU Ram Board P787N LS-4764P Gr A+
$13.98
For Dell Inspiron Mini 10 Series OEM 1.33GHz CPU Ram Board P787N LS-4764P Gr A+ picture






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