Добавление поля редактирования на всплывающий экран - PullRequest
0 голосов
/ 13 марта 2011

Я создал свой собственный всплывающий экран, к которому сейчас пытаюсь добавить поле редактирования, все вроде бы нормально, но проблема в том, что я не могу ничего написать в поле редактирования

class sveetIt extends PopupScreen implements FieldChangeListener, DialogClosedListener {

    Hashtable pitemData;
    ButtonField sveetNowlabelField;
    ButtonField sveetLaterlabelField;
    WatingScreen watingScreen;
    long scheduledTime;
    Dialog updateDialog;

    public sveetIt() {
        super(new MyCustimGridFieldManager());
            LabelField messageLabelField = new LabelField("Enter your Sveet Message:",Field.FIELD_HCENTER) {
            protected void paint(Graphics graphics) {
                graphics.setColor(Color.YELLOWGREEN);
                super.paint(graphics);
            }
        };
    EditField sveetTexteditField= new EditField(null, "Sveet Message", 50, EditField.FIELD_HCENTER
                    | EditField.FIELD_VCENTER 
                    | EditField.NON_SPELLCHECKABLE | EditField.NO_NEWLINE);
        VerticalFieldManager buttonVFManager = new VerticalFieldManager(VerticalFieldManager.FIELD_HCENTER);
        HorizontalFieldManager hfManager = new HorizontalFieldManager();
        sveetNowlabelField = new ButtonField("Sveet Now");
        sveetLaterlabelField = new ButtonField("Sveet Later");
        sveetNowlabelField.setChangeListener(this);
        sveetLaterlabelField.setChangeListener(this);
        add(messageLabelField);
        add(sveetTexteditField);
        hfManager.add(sveetNowlabelField);
        hfManager.add(sveetLaterlabelField);
        buttonVFManager.add(hfManager);
        add(buttonVFManager);
    }
    public boolean isEditable() {
        return true;
    }

    protected boolean keyChar(char c, int status, int time) {
        boolean retVal = false;

        if (c == Characters.ESCAPE) {
            Ui.getUiEngine().popScreen(this);
            retVal = super.keyChar(c, status, time);

        }
        return retVal;
    }

    public void fieldChanged(Field field, int context) {
        if (sveetNowlabelField == field) {          

            //Here directly starts uploading file
            beginUpload();
        } else if (sveetLaterlabelField == field) {
            // first picks up time when to upload
            scheduledTime = getScheduleTime();
            if(scheduledTime!=1L) {
                //now begins uploading file
                beginUpload();
            }
    }}

    class SubscribingThread extends StoppableThread {
        int network = 50;

        public void run() {

        }
    }

    public void beginUpload() {
        try {
            watingScreen = new WatingScreen("Uploading Sveet...");
            /*
             * UiApplication.getUiApplication().invokeAndWait( new Runnable() {
             * public void run() { Ui.getUiEngine().pushScreen(watingScreen); }
             * });
             */
            BaseScreen.pushScreen(watingScreen);
            Thread thread = new Thread(new Runnable() {
                public void run() {
                    uploadToServer();
                }
            });
            thread.start();
            // uploadToServer();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {

        }
    }

    private long getScheduleTime() {
        scheduledTime = 0;
        final DateTimePicker datePick = DateTimePicker.createInstance();
        UiApplication.getUiApplication().invokeAndWait(new Runnable() {
            public void run() {
                // TODO Auto-generated method stub
                Calendar currentCalendar = datePick.getDateTime();
                datePick.setMinimumDate(currentCalendar);
                datePick.doModal();
                Calendar cal = datePick.getDateTime();
                if (cal.after(currentCalendar)) {
                    Date date = cal.getTime();
                    Dialog.alert("You selected " + date.toString());
                    scheduledTime = date.getTime();
                } else {
                    Dialog.alert("Invalid date selection");
                    scheduledTime = 1L;
                }
            }
        });

        System.out.println("date in MilliSeconds is:" + scheduledTime);
        return scheduledTime;
    }

public void uploadToServer() {

    }   public void dialogClosed(Dialog arg0, int arg1) {

    }
}

class MyCustimGridFieldManager extends VerticalFieldManager {

    public MyCustimGridFieldManager() {
        super(VERTICAL_SCROLL | USE_ALL_WIDTH | FIELD_HCENTER);
    }

    protected void paint(Graphics gr) {
        super.paint(gr);
    }

}

Ответы [ 2 ]

0 голосов
/ 14 марта 2011

Попробуйте добавить Field.EDITABLE к вашему стилю для EditField.

0 голосов
/ 13 марта 2011

попробуйте это:

    protected boolean keyChar(char c, int status, int time) {


    if (c == Characters.ESCAPE) {
        Ui.getUiEngine().popScreen(this);        

    }

    return super.keyChar(c, status, time);
}
...