I need to develop the blackberry application using jave (eclips), can you please help me what are the events for dropdown and how to read the value of dropdown list , i tried using getText() method but its given error, can u please give small example on dropdown list in blackberry
final String[] data = {"A", "B","C","D"};
ObjectChoiceField ocf = new ObjectChoiceField("Set your status", data);
ocf.setChangeListener(new FieldChangeListener(){
public void fieldChanged(Field field, int context) {
if(context != PROGRAMMATIC)
Dialog.alert(data[ocf.getSelectedIndex()]);
}
});
Related
Hi am trying to display objectchoicefield by set of data in array.by selecting that comparing with other array automatically another objectchoicefield should get display with corresponding matches.i.e, onchange function, the other objectchoicefield should get load with values.guide me.
Document document=generalXmlAccess.access(generalXmlAccess.getArea());
NodeList list2=document.getElementsByTagName("tuple");
final String[] area = new String [list2.getLength()];
final String[] areaid = new String [list2.getLength()];
for(int i=0;i<list2.getLength();i++)
{
NodeList list=document.getElementsByTagName("NAME");
NodeList list3=document.getElementsByTagName("ROW_ID");
area[i]=list.item(i).getFirstChild().toString()+"-"+list3.item(i).getFirstChild().toString();
areaid[i]=list3.item(i).getFirstChild().toString();
}
final ObjectChoiceField choiceField=new ObjectChoiceField("Select Area",area);
choiceField.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
if(field.equals(choiceField))
{
int index=choiceField.getSelectedIndex();
String values=areaid[index].toString();
Document document1=generalXmlAccess.access(generalXmlAccess.getSubArea());
NodeList list3=document1.getElementsByTagName("tuple");
for(int i=0;i<list3.getLength();i++)
{
subareaid=new String[list3.getLength()];
NodeList nodeList=document1.getElementsByTagName("PAR_ROW_ID");
if(nodeList.item(i).getFirstChild().toString().equals(values))
{
NodeList list=document1.getElementsByTagName("NAME");
subareaid[i]=list.item(i).getFirstChild().toString();
}
add(new ObjectChoiceField("Subarea", subareaid));
}
}
}
});
choiceField.setFont(font1);
I think, following steps might guide you.
Step 1: Create first objectchoicefield with its data.
Step 2: Implement its field change listener, in which you will use the selected value of first choicefield as parameter to get the array of corresponding values to be set to second objectchoicefield ..
Hi Friend's i want to show details when i click on this list field with image(location)means u take any lat long and show with it a image map.so please help me to solve this problem.
How is it possible please help me.
Thanks
on this link show the list field i am also create like this listfiled and when i click and show details with image map
How is it possible please help me.
Thanks
Here I am giving some example try this (assign index to each field in the list view). You can display your details in NewsScreen().
protected boolean navigationClick(int status, int time) {
int index;
System.out.println("CLICKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
index = this.getFieldWithFocusIndex();
UiApplication.getUiApplication().invokeLater(new Runnable(){
public void run() {
UiApplication.getUiApplication().pushScreen(new NewsScreen());
}
});
System.out.println("OUTPUTTTTTTTTTTTTTTT"+this.getFieldWithFocusIndex());
return true;
}
you could pass the image map String URI or bitmap byte to the other screen and show it
UiApplication.getUiApplication().invokeLater(new Runnable(){
public void run() {
UiApplication.getUiApplication().pushScreen(new NewsScreen(IMAGE MAP STRING));
}
});
I am trying to set a common listener for an Customized button and Bitmap field.I am able to reach in listener but not able to differentiate between two fields.
private class MeaningsDetailsPageListner implements FieldChangeListener{
public void fieldChanged(Field field, int arg1) {
Dialog.alert("Hi");
if(field == bField){
Dialog.alert("Image Clicked");
}else if(field == wordBtn){
Dialog.alert("Button Clicked!!");
}
}
}
In following code wordBtn is my customised button and other is BitmapField.I am getting Hi alert but not able to differentiate further.
Any help would be appreciated.
Although I see what you're trying to do, you're better off adding a FieldChangeListener to each Field individually as an anonymous class. This way you don't have to worry about casting your Field to the correct type when testing for equality inside fieldChanged.
ButtonField b = new ButtonField("Hello!");
b.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
Dialog.alert("Button clicked");
}
});
In my application there is one ObjectChoiceField in MainScreen
i want to get change Listner of ObjectChoiceField after click on index 0.
i had already get click event of ObjectChoiceField after click on index grater than 1 and so on ..
so how can i get instance click event after click on ObjectChoiceField ?
I am not really sure what you are asking for.
In your FieldChangeListener.fieldChanged() method, calling ObjectChoiceField.getSelectedIndex() tells you which index is currently selected. You can look for index 0 from that.
If that is not what you need, then you need to clarify your question better.
ObjectChoiceField choiceField = new ObjectChoiceField();
public void fieldChanged(Field field, int context) {
if(field.equals(choiceField))
{
if(choiceField.getSelectedIndex==0)
{your Code}
}
If you want the value which the user have selected you can do by this way too
ObjectChoiceField choiceField = new ObjectChoiceField();
public void fieldChanged(Field field, int context) {
if(field.equals(choiceField))
{
if(choiceField.getSelectedIndex==0)
{
int index = choiceField.getSelectedIndex();
String s = (String) objectWeather.getChoice(index);
Dialog.inform("selected value is"+s);
}
}
}
I want my BlackBerry app to open a website when I focus on its name.
Can anybody tell me how to do that?
final LabelField label = new LabelField(url,LabelField.FOCUSABLE);
label.setFocusListener(new FocusChangeListener(){
public void focusChanged(Field field, int eventType) {
if(eventType == FOCUS_GAINED){
BrowserSession bSession = Browser.getDefaultSession();
bSession.displayPage(label.getText());
}
}
});
add(label);