• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FormEntryPrompt类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.javarosa.form.api.FormEntryPrompt的典型用法代码示例。如果您正苦于以下问题:Java FormEntryPrompt类的具体用法?Java FormEntryPrompt怎么用?Java FormEntryPrompt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FormEntryPrompt类属于org.javarosa.form.api包,在下文中一共展示了FormEntryPrompt类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: parseStyle

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
private void parseStyle(GroupDef tabGroupElement, FormIndex groupIndex) {
	FormIndex tabIndex = this.fem.getModel().incrementIndex(groupIndex,true);

	int tabs = tabGroupElement.getChildren().size();
	for (int i = 0; i < tabs; i++) {
		IFormElement element = this.fem.getModel().getForm().getChild(tabIndex);
		if (element instanceof GroupDef) {
			GroupDef tabElement = (GroupDef) element;
			FormEntryCaption tabCaption = this.fem.getModel().getCaptionPrompt(tabIndex);
			String styleName = tabCaption.getIndex().getReference().getNameLast();
			FormIndex inputIndex = this.fem.getModel().incrementIndex(tabIndex, true);
			Map<String, String> attributes = new HashMap<String, String>();
			for (int j = 0; j < tabElement.getChildren().size(); j++) {
				FormEntryPrompt input = this.fem.getModel().getQuestionPrompt(inputIndex);
				String attributeName = input.getIndex().getReference().getNameLast();
				String attributeValue = input.getQuestionText();
				attributes.put(attributeName, attributeValue);
				inputIndex = this.fem.getModel().incrementIndex(inputIndex, false);
			}
			styles.put(styleName, attributes);
		}

		tabIndex = this.fem.getModel().incrementIndex(tabIndex, false);
	}
}
 
开发者ID:FAIMS,项目名称:faims-android,代码行数:26,代码来源:UIRenderer.java


示例2: getAnswers

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
/**
 * @return a HashMap of answers entered by the user for this set of widgets
 */
public LinkedHashMap<FormIndex, IAnswerData> getAnswers() {
    LinkedHashMap<FormIndex, IAnswerData> answers = new LinkedHashMap<FormIndex, IAnswerData>();
    Iterator<QuestionWidget> i = widgets.iterator();
    while (i.hasNext()) {
        /*
         * The FormEntryPrompt has the FormIndex, which is where the answer gets stored. The
         * QuestionWidget has the answer the user has entered.
         */
        QuestionWidget q = i.next();
        FormEntryPrompt p = q.getPrompt();
        answers.put(p.getIndex(), q.getAnswer());
    }

    return answers;
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:19,代码来源:ODKView.java


示例3: ExIntegerWidget

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
public ExIntegerWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    mAnswer.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED);

    // only allows numbers and no periods
    mAnswer.setKeyListener(new DigitsKeyListener(true, false));

    // ints can only hold 2,147,483,648. we allow 999,999,999
    InputFilter[] fa = new InputFilter[1];
    fa[0] = new InputFilter.LengthFilter(9);
    mAnswer.setFilters(fa);

    Integer i = getIntegerAnswerValue();

    if (i != null) {
        mAnswer.setText(i.toString());
    }
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:20,代码来源:ExIntegerWidget.java


示例4: QuestionWidget

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
public QuestionWidget(Context context, FormEntryPrompt p) {
    super(context);

    mQuestionFontsize = Collect.getQuestionFontsize();
    mAnswerFontsize = mQuestionFontsize + 2;

    mPrompt = p;

    setOrientation(LinearLayout.VERTICAL);
    setGravity(Gravity.TOP);
    setPadding(0, 7, 0, 0);

    mLayout =
        new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
    mLayout.setMargins(10, 0, 10, 0);

    addQuestionText(p);
    addHelpText(p);
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:21,代码来源:QuestionWidget.java


示例5: addHelpText

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
/**
 * Add a TextView containing the help text.
 */
private void addHelpText(FormEntryPrompt p) {

    String s = p.getHelpText();

    if (s != null && !s.equals("")) {
        mHelpText = new TextView(getContext());
        mHelpText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontsize - 3);
        mHelpText.setPadding(0, -5, 0, 7);
        // wrap to the widget of view
        mHelpText.setHorizontallyScrolling(false);
        mHelpText.setText(s);
        mHelpText.setTypeface(null, Typeface.ITALIC);

        addView(mHelpText, mLayout);
    }
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:20,代码来源:QuestionWidget.java


示例6: guessMaxStringLength

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
protected int guessMaxStringLength(FormEntryPrompt prompt) throws UnpivotableExpressionException{
    //Awful. Need factory for this
    //TODO: Negative numbers?
    if(template instanceof IntegerData) {
        IntegerRangeHint hint = new IntegerRangeHint();
        prompt.requestConstraintHint(hint);

        IntegerData maxexample = hint.getMax();
        IntegerData minexample = hint.getMin();

        if(minexample != null) {
            if(((Integer)minexample.getValue()).intValue() < 0) {
                throw new UnpivotableExpressionException();
            }
        }

        if(maxexample != null) {
            int max = ((Integer)maxexample.getValue()).intValue();
            if(!hint.isMaxInclusive()) {
                max -= 1;
            }
            return String.valueOf(max).length();
        }
    }
    throw new UnpivotableExpressionException();
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:27,代码来源:NumericEntryWidget.java


示例7: buildSelectMulti

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
private static QuestionWidget buildSelectMulti(String appearance, FormEntryPrompt fep, Context context) {
    if (appearance != null && appearance.contains("compact")) {
        int numColumns = -1;
        try {
            numColumns =
                    Integer.parseInt(appearance.substring(appearance.indexOf('-') + 1));
        } catch (Exception e) {
            // Do nothing, leave numColumns as -1
            Log.e("WidgetFactory", "Exception parsing numColumns");
        }

        return new GridMultiWidget(context, fep, numColumns);
    } else if (appearance != null && appearance.equals("minimal")) {
        return new SpinnerMultiWidget(context, fep);
    } else if (appearance != null && appearance.equals("list")) {
        return new ListMultiWidget(context, fep, true);
    } else if (appearance != null && appearance.equals("list-nolabel")) {
        return new ListMultiWidget(context, fep, false);
    } else if (appearance != null && appearance.equals("label")) {
        return new LabelWidget(context, fep);
    } else {
        return new SelectMultiWidget(context, fep);
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:25,代码来源:WidgetFactory.java


示例8: validate

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
public void validate(int response, String input, FormEntryPrompt fep) throws BadPlaybackException {
    String message = "Problem with question "+ fep.getQuestionText() + ": ";
    if(response != this.code) {
        if(code == FormEntryController.ANSWER_OK) {
            if(response == FormEntryController.ANSWER_CONSTRAINT_VIOLATED) {
                message += "Input '" +  input + "' was previously valid, but now violates a constraint";
            } else if (code == FormEntryController.ANSWER_REQUIRED_BUT_EMPTY) {
                message += " This question is now required, but was skipped before.";
            }


            throw new BadPlaybackException(message);

        } else if(code == FormEntryController.ANSWER_CONSTRAINT_VIOLATED) {
            message += " the input '" + input + "' used to violate a constraint";

            throw new BadPlaybackException(message);

        } else if(code == FormEntryController.ANSWER_REQUIRED_BUT_EMPTY) {

            message += " this question used to be required, and is now not required";

            throw new BadPlaybackException(message);
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:27,代码来源:ActionResponse.java


示例9: buildCompactSelectOne

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
private static QuestionWidget buildCompactSelectOne(String appearance,
                                                    FormEntryPrompt fep,
                                                    Context context) {
    int numColumns = -1;
    try {
        numColumns =
                Integer.parseInt(appearance.substring(appearance.indexOf('-') + 1));
    } catch (Exception e) {
        // Do nothing, leave numColumns as -1
        Log.e("WidgetFactory", "Exception parsing numColumns");
    }

    if (appearance.contains("quick")) {
        return new GridWidget(context, fep, numColumns, true);
    } else {
        return new GridWidget(context, fep, numColumns, false);
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:19,代码来源:WidgetFactory.java


示例10: getImageItem

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
public static ImageItem getImageItem(FormEntryPrompt fep,int height,int width) {
    String IaltText;

    IaltText = fep.getShortText();
    Image im = ImageUtils.getImage(fep.getImageText());
    if(im!=null){

        //scale
        int[] newDimension = ImageUtils.getNewDimensions(im, height, width);

        if(newDimension[0] != height || newDimension[1] != width) {
            im = ImageUtils.resizeImage(im, newDimension[1], newDimension[0]);
        }

        ImageItem imItem = new ImageItem(null,im, ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_VCENTER, IaltText);
        imItem.setLayout(Item.LAYOUT_CENTER);
        return imItem;
    }else{
        return null;
    }

}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:23,代码来源:ExpandedWidget.java


示例11: getDrawableIDFor

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
private static int getDrawableIDFor(FormEntryPrompt fep) {
    switch (fep.getDataType()) {
        case Constants.DATATYPE_TEXT:
            return R.drawable.avatar_vellum_text;
        case Constants.DATATYPE_INTEGER:
            return R.drawable.avatar_vellum_integer;
        case Constants.DATATYPE_DECIMAL:
            return R.drawable.avatar_vellum_decimal;
        case Constants.DATATYPE_DATE:
            return R.drawable.avatar_vellum_date;
        case Constants.DATATYPE_DATE_TIME:
            return R.drawable.avatar_vellum_datetime;
        case Constants.DATATYPE_CHOICE:
            return R.drawable.avatar_vellum_single_answer;
        case Constants.DATATYPE_CHOICE_LIST:
            return R.drawable.avatar_vellum_multi_answer;
        case Constants.DATATYPE_GEOPOINT:
            return R.drawable.avatar_vellum_gps;
        case Constants.DATATYPE_BARCODE:
            return R.drawable.avatar_vellum_barcode;
    }
    return -1;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:24,代码来源:FormHierarchyBuilder.java


示例12: getQuestionType

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
public static QuestionType getQuestionType(FormController formController) throws Exception{
	FormEntryPrompt formEntryPrompt = formController.getQuestionPrompt();

	switch(formEntryPrompt.getDataType()){
	case Constants.DATATYPE_TEXT:
		return new StringQuestion(formController);
	case Constants.DATATYPE_INTEGER:
		return new StringQuestion(formController);
	case Constants.DATATYPE_CHOICE:
		return new SingleOptionQuestion(formController);
	case Constants.DATATYPE_CHOICE_LIST:
		return new ChoiceListQuestion(formController);
	default:
		throw new Exception("Unsupported Question Type");
	}
}
 
开发者ID:smap-consulting,项目名称:smap-survey-manager,代码行数:17,代码来源:QuestionTypeFactory.java


示例13: countUnansweredQuestions

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
/**
 * @param countRequiredOnly
 *            if true count only the questions that are unanswered and also
 *            required
 * @return number of unanswered questions
 */
public static int countUnansweredQuestions(FormEntryModel model, boolean countRequiredOnly) {
    //ctsims - Made this list only count relevant questions
    int counter = 0;

    for(FormIndex index = model.incrementIndex(FormIndex.createBeginningOfFormIndex());!index.isEndOfFormIndex();index = model.incrementIndex(index)) {
        if(!model.isIndexRelevant(index)) {
            continue;
        }

        if(model.getEvent(index) == FormEntryController.EVENT_QUESTION) {
            FormEntryPrompt prompt = model.getQuestionPrompt(index);
            if(prompt.getAnswerValue() == null) {
                if(!countRequiredOnly || prompt.isRequired()) {
                    counter++;
                }
            }
        }
    }

    return counter;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:28,代码来源:FormSummaryController.java


示例14: getWidget

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
/**
 * NOTE: Only applicable for Questions right now, not any other kind of IFormElement
 * @param questionIndex
 * @param form
 * @param initViewState
 * @return
 */
public ChatterboxWidget getWidget (FormIndex questionIndex, FormEntryModel model, int initViewState) {
    IWidgetStyle collapsedStyle = null;
    IWidgetStyleEditable expandedStyle = null;

    FormEntryPrompt prompt = model.getQuestionPrompt(questionIndex);

    int controlType = prompt.getControlType();
    int dataType = prompt.getDataType();

    String appearanceAttr = prompt.getAppearanceHint();

    collapsedStyle = new CollapsedWidget();
    ((CollapsedWidget)collapsedStyle).setSeekable(this.readOnly);

    expandedStyle = widgetFactory.getWidget(controlType,dataType,appearanceAttr);

    if (collapsedStyle == null || expandedStyle == null) {
        throw new IllegalStateException("No appropriate widget to render question");
    }

    expandedStyle.registerMultimediaController(mediaController);
    ChatterboxWidget widget = new ChatterboxWidget(cbox, prompt, initViewState, collapsedStyle, expandedStyle);
    prompt.register(widget);
    return widget;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:33,代码来源:ChatterboxWidgetFactory.java


示例15: JrFormEntryController

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
public JrFormEntryController(JrFormEntryModel model, String extraKeyMode, boolean audioFailFast, boolean quickEntry, boolean isMinimal) {
    super(model);
    tryToInitDefaultLanguage(model);
    this.extraKeyMode = extraKeyMode;
    this.audioFailFast = audioFailFast;
    this.quickEntry = quickEntry;
    this.isMinimal = isMinimal;

    this.mMediaLogger = new PlayerListener() {
        public void playerUpdate(Player player, String event, Object eventData) {
            FormEntryPrompt fep = JrFormEntryController.this.getModel().getQuestionPrompt();
            try {
                if (fep != null && fep.getAudioText() != null) {
                    MediaUtils.logEvent(event, fep.getAudioText());
                }
            } catch(Exception e) {
                //Nothing
            }
        }
    };

    //#if device.identifier == Sony-Ericsson/K610i
    POUND_KEYCODE = Canvas.KEY_STAR;
    //#endif
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:26,代码来源:JrFormEntryController.java


示例16: question

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
private void question(FormEntryPrompt fep) {
    String text = fep.getQuestionText();
    out.println(text);

    Vector<SelectChoice> choices = fep.getSelectChoices();
    if (choices != null) {
        initSelectList(fep);
        for (int i = 0; i < choices.size(); ++i) {
            String prefix = "";
            if (fep.getControlType() == Constants.CONTROL_SELECT_MULTI) {
                prefix = "[" + (mCurrentSelectList[i] ? "X" : " ") + "] ";
            }
            System.out.println(prefix + (i + 1) + ") " + fep.getSelectChoiceText(choices.elementAt(i)));
        }
    }

    if (fep.getControlType() == Constants.CONTROL_TRIGGER) {
        System.out.println("Press Return to Proceed");
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:21,代码来源:XFormPlayer.java


示例17: getHintText

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
private String getHintText(FormEntryPrompt[] questionPrompts) {
    //Figure out if we share hint text between questions
    String hintText = null;
    if (questionPrompts.length > 1) {
        hintText = questionPrompts[0].getHintText();
        for (FormEntryPrompt p : questionPrompts) {
            //If something doesn't have hint text at all,
            //bail
            String curHintText = p.getHintText();
            //Otherwise see if it matches
            if (curHintText == null || !curHintText.equals(hintText)) {
                //If not, we can't do this trick
                hintText = null;
                break;
            }
        }
    }

    return hintText;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:21,代码来源:QuestionsView.java


示例18: addQuestionEntry

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
private void addQuestionEntry() {
    FormEntryPrompt fp = FormEntryActivity.mFormController.getQuestionPrompt();

    int fepIcon = getFormEntryPromptIcon(fp);
    String questionText;
    boolean isError = false;
    try {
        questionText = fp.getLongText();
    } catch (XPathTypeMismatchException e) {
        questionText = e.getMessage();
        isError = true;
    }
    formList.add(new HierarchyElement(context, questionText, fp.getAnswerText(),
            fepIcon == -1 ? null : context.getResources().getDrawable(fepIcon),
            isError, HierarchyEntryType.question, fp.getIndex()));
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:17,代码来源:FormHierarchyBuilder.java


示例19: buildSelectOne

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
private static QuestionWidget buildSelectOne(String appearance, FormEntryPrompt fep, Context context) {
    if (appearance != null && appearance.contains("compact")) {
        return buildCompactSelectOne(appearance, fep, context);
    } else if (appearance != null && appearance.equals("minimal")) {
        return new SpinnerWidget(context, fep);
    } else if (appearance != null && appearance.contains("combobox")) {
        return buildComboboxSelectOne(appearance, fep, context);
    } else if (appearance != null && appearance.equals("quick")) {
        return new SelectOneAutoAdvanceWidget(context, fep);
    } else if (appearance != null && appearance.equals("list")) {
        return new ListWidget(context, fep, true);
    } else if (appearance != null && appearance.equals("list-nolabel")) {
        return new ListWidget(context, fep, false);
    } else if (appearance != null && appearance.equals("label")) {
        return new LabelWidget(context, fep);
    } else {
        return new SelectOneWidget(context, fep);
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:20,代码来源:WidgetFactory.java


示例20: MediaWidget

import org.javarosa.form.api.FormEntryPrompt; //导入依赖的package包/类
public MediaWidget(Context context, FormEntryPrompt prompt,
                   PendingCalloutInterface pendingCalloutInterface) {
    super(context, prompt);

    this.pendingCalloutInterface = pendingCalloutInterface;

    mInstanceFolder =
            FormEntryInstanceState.mInstancePath.substring(0,
                    FormEntryInstanceState.mInstancePath.lastIndexOf("/") + 1);

    setOrientation(LinearLayout.VERTICAL);
    initializeButtons();
    setupLayout();

    loadAnswerFromDataModel();
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:17,代码来源:MediaWidget.java



注:本文中的org.javarosa.form.api.FormEntryPrompt类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VibrationEffect类代码示例发布时间:2022-05-22
下一篇:
Java InstantiationStrategy类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap