dcsimg
Casting/converting Textfield to int (using J2MEWTK)
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Marika_Ludmann
Posted On:   Thursday, January 23, 2003 04:53 AM

I am getting userinput via Textfield

private TextField vTypeID;

vTypeID = new TextField("Type ID: ", "", 10, TextField.NUMERIC);

I need to pass vTypeID on to writeRecord method as an integer

public void writeRecord(int id, String desc )

How would I convert the Textfield input to an integer?

Re: Casting/converting Textfield to int (using J2MEWTK)

Posted By:   Eelco_Cramer  
Posted On:   Thursday, January 23, 2003 07:45 AM

This is just basic Java. You can get the value from the TextField as a String object, you can convert that to an integer the same way as in J2SE.



vTypeID = new TextField("Type ID: ", "", 10, TextField.NUMERIC);


... yada yada yada ...


writeRecord(Integer.parseInt(vTypeID.getString()));

About | Sitemap | Contact