1

I want if anyone click a label then it should trigger a function. Like I want if a user clicks a label then it should go to another page. Following is the code I tried.

Thanks in Advance!!

LabelField joinGroups = new LabelField("Join Groups",LabelField.FOCUSABLE ){
              protected void layout(int width, int height) {
                  super.layout(width, height);
                  this.setExtent(1000, 44);
                   }
              };

 FChangeListener customListenerSurveys = new FieldChangeListener() {   
                         public void fieldChanged(Field field, int context) {    

                            Dialog.alert("Surveys Clicked!");
                         }
                         };
joinGroups.setFocusListener(customListenerSurveys);
Ahmad Shahwaiz
  • 1,432
  • 1
  • 17
  • 35
  • Solved! Correct code is in the description now.! – Ahmad Shahwaiz Oct 03 '12 at 10:12
  • I agree that your solution is a good one, but in the future, if you find an **answer** to your own **question**, post it as an answer below, not by putting the code back into the question. You can even **accept** your own answer, if you think it's the best solution. Thanks. – Nate Oct 03 '12 at 23:46

1 Answers1

3

Try Navigation Clack.

LabelField joinGroups = new LabelField("Join Groups",LabelField.FOCUSABLE ){
    protected boolean navigationClick(int status, int time){
    Dialog.alert("Surveys Clicked!");
    return true;
    }
 };

enter image description here

Rince Thomas
  • 4,158
  • 5
  • 25
  • 44