Search code examples
blackberryblackberry-editfield

use text entred at EditField in xml parse


i have two classes, one named Main other is Results

(a) the Main class screen have 2 fields:
1- EditField
2- ButtonField


(b) Result class: in this class there is url connection

i want once i click on the ButtonField it go to the other screen with the data i entred in the EditField to parse the xml accourding to my submit text

like this :

http://www.test.com/search.php?q=[ i want the text in the EditField to be here ]

pleaase i have been trying for 2 weeks
i'm very very new at BlackBerry development


Solution

  • okkk you can make one constructor having parameter is of String type of the Resultclass. Get the String from EditField in Button Click From your Main class like this way

    Strnig urlString = youreditfield.getText();//this will be in fieldChanged or any method
     you have used for pushing the Screen
    

    and pass this String to that class which you are pushing from the button click like this way

    UiApplication.getUiApplication().pushScreen(new Result(urlString));
    

    And yourclass constructor would be

    Result(String yourEditfieldurl) {
    
       Assign this url to a variable and use it in Result class that's it 
    
    }
    

    Or you can make a Static variable

    like this In main class make a varible like this

    public static String editFieldUrl;

    assign the value in ButtonField click method editFieldUrl = yourEditfield.getText();

    and use this variable in the other class. I think this may help you.