01-02-2012 06:27 AM
hi.. i need to display drop down list in my screen.. im using objectchoicefield.. i want to list of String Dynamically.. To Add list String Statically not problem. i can like this
String[ ] choice = {"hi","hello","how"," when"};
how to add this things dynamically.. pls help out
01-02-2012 06:40 AM - last edited on 01-02-2012 06:40 AM
Hi Vimal,
You can't add strings dynamically to string array, insted of that u can use StringBuffer or u can use vector.
My suggestion is use Vectors ,in that u can add or remove what ever u want....
In object choicefield also write vector.elementAt(index).toString()..
Thanks..
Lakshman
01-02-2012 06:41 AM
You can use
Arrays.add(Object[] arg0, Object arg1);
to add an element to an existing array.
01-02-2012 06:44 AM - last edited on 01-02-2012 07:35 AM
take the array length and give like this
String[ ] choice = new String[length];
now you can add the Strings to that array by this
choice[array_index] = "your required string";
01-02-2012 07:40 AM
01-02-2012 07:58 AM
01-02-2012 08:00 AM
Hi,
Vector v = new Vector();
v.addElement();.....
ObjectChoiceField obj = new ObjectChoiceField();
String s[] = new String[v.size()];
for(int i =0; i < v.size(); i++)
{
s[i] = v.elementAt(i).toString();
}
obj.setChoices(s);
Like this u can add...
Thanks,
Lakshman
01-02-2012 08:18 AM