j2me+choice group
I am working on the project where i had used choice group in form. Now I wan开发者_StackOverflow社区t to get the selected item or index number of the choice group and want to perform some action.
I had tried through this:-
System.out.println(cgPrefs.getString(i) + (selected[i] ? ": selected" : ": not selected"))
;
But I am not getting the exact index number of the selected item in choice group.
You will get flags according to selection
boolean[] selectedFlag = new boolean[getChoiceGroup().size()];
using getSelectedFlags()
method
getChoiceGroup().getSelectedFlags(selectedFlag);//getChoiceGroup() returns object of choicegroup
Now iterate and print
for(int i = 0 ; i < selectedFlag.length; i ++){
if(selectedFlag[i]){
System.out.println("Selected : "+getChoiceGroup().getString(i));
}else{
System.out.println("Not Selected : "+getChoiceGroup().getString(i));
}
}
精彩评论