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
fxwahyugomugomu
Posts: 20
Registered: ‎04-14-2010
My Device: tour 9650
My Carrier: indosat
Accepted Solution

[ASK] how to EditField automatic resize

[ Edited ]

i have a code.. 

public class AppMainScreen extends MainScreen implements HttpResponseListener {
    private final String URL = "http://translate.google.com/m?hl=id&sl=id&tl=hi&ie=UTF-8&prev=_m&q=aku+lapar";

    public AppMainScreen(String title) {
        setTitle(title);
		
		txtHasil = new EditField("", "", EditField.DEFAULT_MAXCHARS, FOCUSABLE);
            add(txtHasil);
    }

    private MenuItem miReadData = new MenuItem("Read data", 0, 0) {
        public void run() {
            requestData();
        }
    };

    protected void makeMenu(Menu menu, int instance) {
        menu.add(miReadData);
        super.makeMenu(menu, instance);
    }

    public void close() {
        super.close();
    }

    public void showDialog(final String message) {
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                Dialog.alert(message);
            }
        });
    }

    private void requestData() {
        Thread urlReader = new Thread(new HttpUrlReader(URL, this));
        urlReader.start();
    }

    public void onHttpResponseFail(String message, String url) {
    }

    public void onHttpResponseSuccess(byte bytes[], String url) {
        string hasil(""+ new String(bytes));
		txtHasil.setText(hasil);

       
    }
}

 when i select the menu item read, going out like this

output before

 

I want output in editfield

I want output in editfield

 

please help me, im stuck in Editfield.. :'(

Please use plain text.
Developer
developer_aman_arora
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: [ASK] how to EditField automatic resize

print like this

String string = new String(bytes);
txtHasil.setText(string);

and see whether working or not?
Please use plain text.
Contributor
fxwahyugomugomu
Posts: 20
Registered: ‎04-14-2010
My Device: tour 9650
My Carrier: indosat

Re: [ASK] how to EditField automatic resize

not work.. same, editfield not otomatic resize.. :smileysad:
Please use plain text.
Developer
developer_aman_arora
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: [ASK] how to EditField automatic resize

What u get when you print string or hasil?
Please use plain text.
Contributor
fxwahyugomugomu
Posts: 20
Registered: ‎04-14-2010
My Device: tour 9650
My Carrier: indosat

Re: [ASK] how to EditField automatic resize

i get result parssing URL...

 

parssing out the results in editfield...

 

image xample parsing result

 

Please use plain text.
Contributor
fxwahyugomugomu
Posts: 20
Registered: ‎04-14-2010
My Device: tour 9650
My Carrier: indosat

Re: [ASK] how to EditField automatic resize

My problem is, parsing results in the edit field doesnt look all, only one line is visible .. I want to look all the parsing results in editfield.
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: [ASK] how to EditField automatic resize

Is "onHttpResponseSuccess()" called on the Event Thread?  Try the following just to make sure that the field update is run on the Event Thread

 

    public void onHttpResponseSuccess(final byte bytes[], String url) {
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                  txtHasil.setText(new String(bytes));
            }
        });
    }

 

If this does not work, then please put a try catch around this code to make sure it is not throwing some Exception.  Let us know what you see. 

Please use plain text.
Contributor
fxwahyugomugomu
Posts: 20
Registered: ‎04-14-2010
My Device: tour 9650
My Carrier: indosat

Re: [ASK] how to EditField automatic resize

peter_strange thank you so much.. #bighug
Please use plain text.