2012-08-30 2 views
1

드롭 다운 표시하지 않는 것은 아래의 코드 때문에 작동하지 ObjectChoiceField : 나는 touchevent의 메뉴를 제거하려면이 코드를 추가 한 블랙 베리 ObjectChoiceField 목록

protected boolean navigationUnclick(int status, int time) { 
    return true; 
} 

. 즉, 사용자 정의 하단 탭을 만들고 화면에 수직 필드를 추가 및 삭제합니다. HorizontalField를 터치하면 위의 코드를 추가 한 이유가있는 메뉴가 표시됩니다.

내 코드는 ObjectChoiceField가 horizontalfield에 추가 포함이되어

import net.rim.device.api.system.Bitmap; 
import net.rim.device.api.system.EncodedImage; 
import net.rim.device.api.ui.Color; 
import net.rim.device.api.ui.Field; 
import net.rim.device.api.ui.FieldChangeListener; 
import net.rim.device.api.ui.Graphics; 
import net.rim.device.api.ui.TouchEvent; 
import net.rim.device.api.ui.component.BitmapField; 
import net.rim.device.api.ui.component.ButtonField; 
import net.rim.device.api.ui.component.LabelField; 
import net.rim.device.api.ui.component.ObjectChoiceField; 
import net.rim.device.api.ui.container.VerticalFieldManager; 

import com.ec.pleasewaitpopup.PleaseWaitPopupScreen; 
import com.np.naijapings.ApplicationFont; 
import com.np.naijapings.Constant; 
import com.np.naijapings.TabControlScreen; 
import com.np.naijapings.intermediateclasses.GetUserListIntermediator; 
import com.tv.servercommunication.WebServiceDetails; 

public class FindUsersScreen extends VerticalFieldManager implements FieldChangeListener{ 

    private VerticalFieldManager _mainVfm; 
    private VerticalFieldManager _contentVfm; 

    private BitmapField _headerBmp; 
    private EncodedImage _bitmap; 

    private LabelField _gender; 
    private LabelField _age; 
    private LabelField _religion; 

    private ObjectChoiceField _genderChoiceField; 
    private ObjectChoiceField _ageChoiceField; 
    private ObjectChoiceField _religionChoiceField; 

    private ButtonField _findUser; 

    private static String[] _genderChoices={"Both gender","Male","Female"}; 
    private static String[] _ageChoices={"Any age","18-25","26-30","31-35","36-45","46-50"}; 
    private String[] _religionChoices={"Any religion","Hindu","Muslim"}; 

    public FindUsersScreen(){ 
     //HEADER IMG 
     _bitmap = EncodedImage. 
     getEncodedImageResource("find-user_header.png"); 
     _headerBmp = new BitmapField(Constant.sizePic(_bitmap, _bitmap.getHeight(), _bitmap.getWidth())); 

     //MAIN VFM 
     _mainVfm=new VerticalFieldManager(); 

     //CONTENT VFM 
     final Bitmap tabBackGroundImage = Bitmap 
     .getBitmapResource("finduserscr_bg.png"); 
     _contentVfm=new VerticalFieldManager(){ 
      protected void paint(Graphics graphics) { 
       int y = FindUsersScreen.this.getManager().getVerticalScroll(); 
       graphics.drawBitmap(0, y, tabBackGroundImage.getWidth(), tabBackGroundImage.getHeight(), tabBackGroundImage, 0, 0); 
       super.paint(graphics); 
       } 
     }; 

     //CREATE WIDGETS 
     _gender=new LabelField("Gender"); 
     _genderChoiceField=new ObjectChoiceField("Gender", _genderChoices,0){ 
      protected boolean touchEvent(TouchEvent message) { 

       return super.touchEvent(message); 
      } 
     }; 
     _age=new LabelField("Age"); 
     _ageChoiceField=new ObjectChoiceField("Age", _ageChoices,0); 
     _religion=new LabelField("Religion"); 
     _religionChoiceField=new ObjectChoiceField("Religion", _religionChoices,0); 
     _findUser=new ButtonField(" Find Users ",ButtonField.CONSUME_CLICK); 


     _findUser.setChangeListener(this); 

     //SET FONT TYPE 
     /*_gender.setFont(ApplicationFont.labelFont_16); 
     _genderChoiceField.setFont(ApplicationFont.labelFont_16); 
     _ageChoiceField.setFont(ApplicationFont.labelFont_16); 
     _age.setFont(ApplicationFont.labelFont_20); 
     _religionChoiceField.setFont(ApplicationFont.labelFont_20); 
     _religion.setFont(ApplicationFont.labelFont_20); 
*/ 
     //SET MARGIN 
     /*_gender.setMargin(5,20,5,20); 
     _age.setMargin(5,20,5,20); 
     _religion.setMargin(5,20,5,20); 
    */ 
     _contentVfm.setMargin(15,30,15,0); 
     _genderChoiceField.setMargin(10,5,5,5); 
     _religionChoiceField.setMargin(10,5,5,5); 
     _ageChoiceField.setMargin(10,5,5,5); 
     _findUser.setMargin(10,80,20,80); 
     _contentVfm.setMargin(30,10,30,10); 

     //ADD FIELDS TO CONTENT VFM 
     //_contentVfm.add(_gender); 
     _contentVfm.add(_genderChoiceField); 
     //_contentVfm.add(_age); 
     _contentVfm.add(_ageChoiceField); 
     //_contentVfm.add(_religion); 
     _contentVfm.add(_religionChoiceField); 
     _contentVfm.add(_findUser); 
     _mainVfm.add(_headerBmp); 
     _mainVfm.add(_contentVfm); 
     add(_mainVfm); 
    } 

    public void fieldChanged(Field field, int context) { 
     if(field==_findUser){ 
      Object obAgeRange = _ageChoiceField.getChoice(_ageChoiceField.getSelectedIndex()); 
      String ageRange = obAgeRange.toString(); 

      Object obgender = _genderChoiceField.getChoice(_genderChoiceField.getSelectedIndex()); 
      String gender = obgender.toString(); 

      Object obReligion = _religionChoiceField.getChoice(_religionChoiceField.getSelectedIndex()); 
      String religion = obReligion.toString(); 

      GetUserListIntermediator getUserListIntermediator=new GetUserListIntermediator(ageRange,gender,religion); 
      PleaseWaitPopupScreen.showScreenAndWait(getUserListIntermediator, Constant.PLEASE_WAIT_TEXT); 
     } 
    } 

} 

는 사람이 어떻게이 문제를 해결하는 내 질문에 대답 할 수있다.

+0

왜 터치 이벤트를 탐색 클릭 이벤트에 연결 했습니까? –

답변

2

필드 코드가 unclick 이벤트를 처리하지 않기 때문에 드롭 다운 목록을 가져올 수 없습니다. 필드에서 처리하기 전에이 이벤트를 가로 채고 사용했습니다 (return true; 경유).

이벤트 처리기에이 코드를 사용해보십시오.

protected boolean navigationUnclick(int status, int time) { 
     super.navigationUnclick(status, time); 
     return true; 
}