BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-15-2007, 07:25 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 Custom Buttons Problem

Please Login to Remove!

I have gone through the CustumButton app .but i am not able to figure out how to interact with custombuttons.As in they dont react when i click on them even after i do "setChangeLstener".i think this does not work bcos the state of the buttons does not change.

I want to perform an action when i click on the custombutton.i am working on it but havent yet figured out how.

could someone pls help.
__________________
Thanks
Meenal
Offline  
Old 05-15-2007, 07:38 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

does this work?

ButtonField okButton = new ButtonField("OK", ButtonField.CONSUME_CLICK);

okButton.setChangeListener(new FieldChangeListener(){
public void fieldChanged(Field field, int context){
Status.show("You clicked the button");
}
});
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 05-15-2007, 07:59 AM   #3 (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

no it does not work.when i click on the button it shows me the default menu.
here the code i have:
Code:
Rectangle =  new CustomButtonField("rectangle",CustomButtonField.RECTANGLE,Field.FOCUSABLE) ;
mainScreen.add(Rectangle);
 Rectangle.setChangeListener(new FieldChangeListener(){
public void fieldChanged(Field field, int context){
Status.show("You clicked the button");
}
});
__________________
Thanks
Meenal
Offline  
Old 05-15-2007, 09:46 AM   #4 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Replace your CustomButtonField with the above code - does that work? If it does the problem lies with when you create your custom buttom - are you following the CustomButtonField example correctly? - this isn't part of the api - it's just an example of an object that extends Field if i remember correctly, the full source is available in the Application Developer Guide pdf
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 05-16-2007, 12:19 AM   #5 (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

what i want to do is that use certen icon for gui...thats y i was refering to custombuttons application....but i cannot figure out perform an action when i click on them....focus come alright.I dont know where i am missing out on.Infact i have modifyed the same program.but i am not able to make it listen to trackwheel click.

will i have to use it a TrachWheelListener()?

Or could u suggest where i am missing?
Its the same example...i have just replaced the shapes with bitmaps.

Thank You
__________________
Thanks
Meenal
Offline  
Old 05-16-2007, 02:52 AM   #6 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You don't need to create a new custom object to do that, you can use overrides on the BitmapField object, the code below includes a rollover icon:

BitmapField myField = new BitmapField(icon1, BitmapField.FOCUSABLE | BitmapField.FIELD_HCENTER | BitmapField.FIELD_VCENTER){
public void onFocus(int direction){
setBitmap(icon2);
//optionally do something on rollover
}
public void onUnfocus(){
super.onUnfocus();
setBitmap(icon1);
}
public boolean trackwheelClick(int status, int time){
Status.show("button clicked");
return true;
}
};
add(myField);
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 05-16-2007, 04:31 AM   #7 (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

Thank u....it worked.

Just one more question.
Can we change the BackGround color of a ButtonField.i tried using setBackgroundColor(Color.Red) ... but yet it remained either blue(onfocus) and otherwise gray.

using the setBackgroundColor(Color.Red) method i managed to change background color of LabelField....but havent been able to do for ButtonField.
Code:
ButtonField btn1 = new ButtonField("Button 1") {
    protected void paint(Graphics g) {
         g.drawBitmap(0,0, mybitmap1.getHeight() , ybitmap.getWidth), mybitmap1 ,  0, 0);
         g.setBackgroundColor(Color.RED);
    }
     protected void layout(int width,int height) {
          setExtent(mybitmap1.getHeight(),mybitmap1.getWidth());
     }
};
__________________
Thanks
Meenal
Offline  
Old 05-16-2007, 06:18 AM   #8 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

pretty sure you can't change the colours of the buttons as these are defined by the theme on the device.
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 05-17-2007, 12:02 AM   #9 (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

hmm....thought so.
__________________
Thanks
Meenal
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

NOS Ohmite 100 ohm Potentiometer Linear 2 Watt CU-1011
$14.99
NOS Ohmite 100 ohm Potentiometer Linear 2 Watt CU-1011 picture1x 50K Ohm 3590S-2-503L Potentiometer With 10 Turns Counting Dial Rotary Knob
$6.47
1x 50K Ohm 3590S-2-503L Potentiometer With 10 Turns Counting Dial Rotary Knob picture10 pcs. AD5220BR10 Analog Devices 10K Digital potentiometer SOIC 5220 AD5220
$14.5
10 pcs. AD5220BR10 Analog Devices 10K Digital potentiometer SOIC 5220 AD5220 picturelot of 98 AD5220BR10 Analog Devices 10K Digital potentiometer SOIC 5220 AD5220
$75.0
lot of 98 AD5220BR10 Analog Devices 10K Digital potentiometer SOIC 5220 AD5220 picture50K Ohm Megatron MUNCHEN Praz Potentiometer SMT 10/10 w/Lock Linearity +/- 0.25%
$15.98
50K Ohm Megatron MUNCHEN Praz Potentiometer SMT 10/10 w/Lock Linearity +/- 0.25% picture






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