BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 02-18-2010, 11:50 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Dec 2009
Model: 8520
PIN: N/A
Carrier: Movistar
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help with this App

Please Login to Remove!

Hello, I'm trying to do an App that displays a ChoiceGroup item of the type POPUP to then do other things.

This is my code:

PHP Code:
package com.client.bberry;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import javax.microedition.lcdui.*;

public class 
Opciones extends UiApplication {
    public static 
void main(Stringxxx91;xxx93; args) {
        
Opciones theApp = new Opciones();
        
theApp.enterEventDispatcher();
    }
    
    
    
private 
Opciones() {
        
pushScreen(new OpcionesScreen());
    }
}
final class 
OpcionesScreen extends MainScreen {
   
OpcionesScreen() {
        
         
Form Formita = new Form("Select Option");
        
ChoiceGroup Lista = new ChoiceGroup("Select your option",Choice.POPUP);
        
Lista.append("A",null);
        
Lista.append("B",null);
        
Lista.append("C",null);
        
Formita.append(Lista);
  }  

This just shows and empty white screen. I'm sure I'm missing something very elemental and that you guys will be able to help me out.

Thanks in advance.

Last edited by leonsas : 02-18-2010 at 11:53 PM.
Offline  
Old 02-19-2010, 05:16 AM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2010
Model: 8900
PIN: N/A
Carrier: trainee
Posts: 30
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi!
1st of all, let me clear one thing that,for appending any item on MainScreen u have to add it one screen.
and 2ndly,
if u will try to add or append Form class on MainScreen,it is not possible bcoz
Form is in javax.microedition api while MainScreen is RIM api.

thnks,
Neha
Offline  
Old 02-19-2010, 10:45 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Dec 2009
Model: 8520
PIN: N/A
Carrier: Movistar
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

So I should remove the Form from my code, and how to add one screen, I thought that was accomplished with the pushScreen().

I'm now trying to do it just with RIM's APIs so here's my try

PHP Code:
package com.client.bberry;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import javax.microedition.lcdui.*;
import net.rim.device.api.ui.Field;


public class 
Opciones extends UiApplication {
    public static 
void main(Stringxxx91;xxx93; args) {
        
Opciones theApp = new Opciones();
        
theApp.enterEventDispatcher();
    }
    
    
    
private 
Opciones() {
        
pushScreen(new OpcionesScreen());
    }
}
final class 
OpcionesScreen extends MainScreen {
   
OpcionesScreen() {          
      
       
String opcionxxx91;xxx93; = {"A""B""C"};
     
OpcionesScreen.add(new ObjectChoiceField("Select an option"opcion));

  }  


But I get the following error:


Code:
non-static method add(net.rim.device.api.ui.Field) cannot be referenced from a static context
     OpcionesScreen.add(new ObjectChoiceField("Select an option", opcion));
                   ^
What does that mean?
Thanks.

Last edited by leonsas : 02-19-2010 at 12:24 PM.
Offline  
Old 02-20-2010, 08:59 AM   #4 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2010
Model: 8900
PIN: N/A
Carrier: trainee
Posts: 30
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Reply

Hi!

actually this is basic concept of java,that we cannot reference non static method from static context.
add() method of MainScreen class is non-static method so simple write add(new ObjectChoiceField("Select an option", opcion).
istead of calling it with class name.

thnks
Offline  
Old 02-21-2010, 04:08 PM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Dec 2009
Model: 8520
PIN: N/A
Carrier: Movistar
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, that worked out.
So now I want to add a text field with a NUMERIC constraint, what I wrote was
PHP Code:
 BasicEditField selector = new BasicEditField("Select:","",9,Field.NUMERIC);
add(selector); 
just below the new ObjectChoiceField, but I get the error:
Code:
cannot find symbol
symbol  : variable NUMERIC
and
Code:
internal error; cannot instantiate BasicEditField(java.lang.String,java.lang.String,int,long) at net.rim.device.api.ui.component.BasicEditField to ()
     BasicEditField selector = new BasicEditField("To:","",9,Field.NUMERIC);
                     ^
Thanks for helping me, I'm slowly learning.

Last edited by leonsas : 02-21-2010 at 04:31 PM.
Offline  
Old 02-21-2010, 07:13 PM   #6 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

You want to setFilter() from your BAsicEditField

selector.setFilter(new NumericTextFilter())
Offline  
Old 02-21-2010, 10:17 PM   #7 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2010
Model: 8900
PIN: N/A
Carrier: trainee
Posts: 30
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi!

whenever u r try to add any item is your class,1stly go through its class.

BasicEditField selector = new BasicEditField("Select:","",9,BasicEditField.FILTE R_NUMERIC);

try to learn things from this link.
file:///C:/Program%20Files/Research%20In%20Motion/BlackBerry%20JDE%204.7.0/docs/api/index.html

thnks
Offline  
Old 02-21-2010, 10:24 PM   #8 (permalink)
Knows Where the Search Button Is
 
Join Date: Dec 2009
Model: 8520
PIN: N/A
Carrier: Movistar
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I get
Code:
cannot find symbol
symbol  : class NumericTextFilter
and if I try
PHP Code:
selector.setFilter(new NumericTextFilter(ALLOW_DECIMAL)); 
I also get
Code:
cannot find symbol
symbol  : variable ALLOW_DECIMAL
Thanks for the help, never thought learning java by myself was this hard.


EDIT: neha.chaudhary didn't saw your post, what you said does works, now just to learn I want to know why the setFilter() didn't worked out for me, and yes I'm trying to learn from the API Reference but it sometimes gets confusing.

EDIT #2: While trying to set background I did
PHP Code:
BasicEditField hasta = new BasicEditField("To::","",9,BasicEditField.FILTER_NUMERIC){
        public 
void paint(Graphics g){
        
g.setBackgroundColor(Color.DARKBLUE);
        
g.clear();
        
super.paint(g);
    }
}; 
and it works, but how do I put background to the whole MainScreen?

Last edited by leonsas : 02-21-2010 at 11:33 PM.
Offline  
Old 02-24-2010, 06:28 AM   #9 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2010
Model: 8900
PIN: N/A
Carrier: trainee
Posts: 30
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Reply

hi!

ALLOW_DECIMAL is static field of class NumericTextFilter.so we have to call it using class name.as we knw static variables are called using Class Name.
selector.setFilter(new NumericTextFilter(NumericTextFilter.ALLOW_DECIMAL) );
Offline  
Old 02-24-2010, 02:21 PM   #10 (permalink)
Knows Where the Search Button Is
 
Join Date: Dec 2009
Model: 8520
PIN: N/A
Carrier: Movistar
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nope, it didnt worked.

cannot find symbol
symbol : variable NumericTextFilter
location: class com.client.bberry.OpcionesScreen
selector.setFilter(new NumericTextFilter(NumericTextFilter.ALLOW_DECIMAL) );
Offline  
Old 02-24-2010, 08:50 PM   #11 (permalink)
Knows Where the Search Button Is
 
Join Date: Dec 2009
Model: 8520
PIN: N/A
Carrier: Movistar
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Fixed it, I forgot to import it.
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





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