Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
reve
Posts: 23
Registered: ‎02-09-2011
My Device: Storm 2
Accepted Solution

Image ButtonField

hy guys

this is the problem

 

        BitmapField bfSeat = new BitmapField(Bitmap.getBitmapResource("seat_service.png"), BitmapField.FOCUSABLE);
        bfSeat.setChangeListener(new FieldChangeListener(){     
            public void fieldChanged(Field field, int context) {

 

when i click on the image i see the menu show keyboard, full menu! but i want to invoke the button!

i'va added BitmapField.FOCUSABLE... bot it's dont work..

 

why?

Please use plain text.
Developer
Darknoe
Posts: 92
Registered: ‎02-22-2011
My Device: Not Specified

Re: Image ButtonField

Hi!

 

I'm handling the same problem on my application, try with this example.

 

http://stackoverflow.com/questions/4336097/blackberry-bitmap-listener

 

I will post my solution when i get it to work fine :smileyhappy:

Please use plain text.
Developer
Aman_vivek
Posts: 216
Registered: ‎02-18-2010
My Device: 9350,8520
My Carrier: no

Re: Image ButtonField

Use navigationclick instead of fieldchange.

Please use plain text.
Contributor
reve
Posts: 23
Registered: ‎02-09-2011
My Device: Storm 2

Re: Image ButtonField

mmm i don't understand...

 

if i change

        BitmapField bfSeat = new BitmapField(Bitmap.getBitmapResource("seat_service.png"), BitmapField.FOCUSABLE);
        bfSeat.setChangeListener(new FieldChangeListener(){     
            public void navigationClick(Field field, int context) {

 

FieldChangeListener call an ERROR.

Please use plain text.
Developer
Aman_vivek
Posts: 216
Registered: ‎02-18-2010
My Device: 9350,8520
My Carrier: no

Re: Image ButtonField

Don't use Fieldchange Listener. Use the following function in your class.

protected boolean navigationClick(int status, int time) 
{
 Field f1=getFieldWithFocus().getLeafFieldWithFocus();
  if(f1==bfSeat )
   {
       Dialog.alert("pressed");
   }
 return super.navigationClick(status, time);
}

 

 

Please use plain text.
Contributor
reve
Posts: 23
Registered: ‎02-09-2011
My Device: Storm 2

Re: Image ButtonField

sorry, but i've the controller in my button!

 

this is the original

 

 

       BitmapField bfSeat = new BitmapField(Bitmap.getBitmapResource("seat_service.png"), BitmapField.FOCUSABLE);
        bfSeat.setChangeListener(new FieldChangeListener(){     
            public void fieldChanged(Field field, int context) {
                xmlAssFILE = new XmlAssistanceFile(Constants.FILE_PATH_REGISTRAZIONE + Constants.fileAssistenza);
                String lastTIME = xmlAssFILE.extractLastTimeAssistance();
                boolean isTimeForNewRequest;
                if (lastTIME.equals(""))//è la prima volta che si richiede l'assistenza, il file xml è inesistente
                    isTimeForNewRequest = true;
                else{
                    xmlAssFILE = new XmlAssistanceFile(Constants.FILE_PATH_REGISTRAZIONE + Constants.fileAssistenza);
                    isTimeForNewRequest = isTimeForNewAssistanceRequest(lastTIME);//verifico se sono trascorsi più di 60 secondi dall'ultima segnalazione
                }
                if (textCellAss.equals(iPhone.getNumTelefono().substring(3, iPhone.getNumTelefono().length())) && textPrefCellAss.equals(iPhone.getNumTelefono().substring(0, 3)) ){
                    textPrefCellAss.setText(iPhone.getNumTelefono().substring(0, 3));
                    textCellAss.setText(iPhone.getNumTelefono().substring(3, iPhone.getNumTelefono().length()));
                } else {
                    int dialog = Dialog.ask(Dialog.D_YES_NO, ""+"Sei sicuro di voler modificare il numero di telefono sul quale ricevere l'assistenza?");
                    if (dialog == Dialog.YES){
                        iPhone.setNumTelefono(""+textPrefCellAss.getText()+textCellAss.getText());
                    }
                }
                    
                if (isTimeForNewRequest) {
                    //view.setClickable(false);
                    boolean okFormalControls = verifyFormalControls();//Controllo su obbligatorietà e consistenza dei campi immessi
                    if (!okFormalControls) {//Se i controlli hanno avuto  esito negativo esco per visualizzare l'opportuno messaggio di errore
                        return;
                    } else {
                        boolean networkAvailable = isWirelessActive();//Controllo sulla presenza o meno di una connessione internet
                        if (!networkAvailable) {//Se non c'è rete esco per visualizzare l'opportuno messaggio di errore
                            Dialog.alert(Constants.ALERT_NETWORK_DOWN);
                            return;
                        } else {
                            reqPhone = getRichiestaAssistenza();
                            //boolean assistanceOK = true;
                            boolean assistanceOK = sendAssistanceRequest();//invio la richiesta di assistenza (Chiamata Web Service)
                            if (!assistanceOK) {
                                return;
                            } else {
                                xmlAssFILE = new XmlAssistanceFile(Constants.FILE_PATH_REGISTRAZIONE + Constants.fileAssistenza);
                
                                boolean xmlAssistance = xmlAssFILE.writeXmlAssistanceFile();
                                if (xmlAssistance) {
                                    Dialog.alert(Constants.ALERT_ASSISTANCE_OK);
                                    return;
                                } else {
                                    Dialog.alert(Constants.ALERT_XML_FILE_WRITE_ERROR);
                                    return;
                                }
                            }
                        }
                    }
                }else {
                    return;
                }
            }

        
        });
        //gfImgSeat.add(bfSeat);
        gfImgSeat.add(bfSeat);
        add(gfImgSeat);

 

if i change with navigationclick this call ERROR!

:-(

Please use plain text.
Developer
Aman_vivek
Posts: 216
Registered: ‎02-18-2010
My Device: 9350,8520
My Carrier: no

Re: Image ButtonField

Find attached file. 

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Image ButtonField

Override navigationClick to do nothing (return true) and navigationUnclick to call fieldChangeNotify. Use FieldChangeListener.PROGRAMMATIC as a parameter to fieldChangeNotify if you want the field to never become dirty.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Image ButtonField

Oh, and it seems you have some misconception on how to override the methods of that field. Here is how it might look:

 

BitmapField bfSeat = new BitmapField(Bitmap.getBitmapResource("seat_service.png"), BitmapField.FOCUSABLE) {
  protected boolean navigationClick(int status, int time) {
    return true;
  }

  protected boolean navigationUnclick(int status, int time) {
    fieldChangeNotify(FieldChangeListener.PROGRAMMATIC);
    return true;
  }
};

 

 

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Contributor
reve
Posts: 23
Registered: ‎02-09-2011
My Device: Storm 2

Re: Image ButtonField

many thanks!!!

Please use plain text.