public class QuestionStep extends Step
QuestionStep
class is a concrete subclass of Step
that represents a step in
which a single question is presented to the user.
To use a question step, instantiate an QuestionStep object, fill in its properties, and include
it in a task. When the task completes, the user's answer is encoded in the result hierarchy
returned from the ViewTaskActivity
.
When the ViewTaskActivity presents a QuestionStep object, it instantiates a SurveyStepLayout
object to present the step. The actual visual presentation depends on the
answer format and its StepBody
.
When you need to present more than one question at the same time, it can be appropriate to use
FormStep
instead of QuestionStep.
The result of a question step is an StepResult
object.
Constructor and Description |
---|
QuestionStep(java.lang.String identifier)
Returns a new question step that includes the specified identifier.
|
QuestionStep(java.lang.String identifier,
java.lang.String title)
Returns a new question step that includes the specified identifier, and title.
|
QuestionStep(java.lang.String identifier,
java.lang.String title,
AnswerFormat format)
Returns a new question step that includes the specified identifier, title, and answer
format.
|
Modifier and Type | Method and Description |
---|---|
AnswerFormat |
getAnswerFormat()
Returns the format of the answer.
|
java.lang.String |
getPlaceholder()
Returns a localized string that represents the placeholder text displayed before an answer
has been entered.
|
java.lang.Class<?> |
getStepBodyClass()
Returns a subclass of
StepBody responsible
for creating the ui for answering the question, base on the AnswerFormat. |
java.lang.Class |
getStepLayoutClass()
Returns a special
StepLayout that is used
for all question steps. |
void |
setAnswerFormat(AnswerFormat answerFormat)
Sets the answer format for this question step.
|
void |
setPlaceholder(java.lang.String placeholder)
Sets a localized string that represents the placeholder text displayed before an answer has
been entered.
|
getIdentifier, getStepTitle, getText, getTitle, isOptional, setOptional, setStepLayoutClass, setStepTitle, setText, setTitle
public QuestionStep(java.lang.String identifier)
identifier
- The identifier of the step (a step identifier should be unique within the
task).public QuestionStep(java.lang.String identifier, java.lang.String title)
identifier
- The identifier of the step (a step identifier should be unique within the
task).title
- A localized string that represents the primary text of the question.public QuestionStep(java.lang.String identifier, java.lang.String title, AnswerFormat format)
identifier
- The identifier of the step (a step identifier should be unique within the
task).title
- A localized string that represents the primary text of the question.format
- The format in which the answer is expected.public java.lang.Class getStepLayoutClass()
StepLayout
that is used
for all question steps.
This step layout uses the getStepBodyClass()
to fill in the user interaction portion
of the layout's UI.
getStepLayoutClass
in class Step
public java.lang.Class<?> getStepBodyClass()
StepBody
responsible
for creating the ui for answering the question, base on the AnswerFormat.
This class is used by SurveyStepLayout
to create the part of the layout where the
user answers the question. For example, a StepBody for a simple text question would be
responsible for creating an EditText for the SurveyStepLayout to place inside of its layout.
Override this method with your own StepBody implementation if you create a custom QuestionStep.
public AnswerFormat getAnswerFormat()
For example, the answer format might include the type of data to collect, the constraints to
place on the answer, or a list of available choices (in the case of single or multiple select
questions). It also provides the default StepBody
for questions of its type.
public void setAnswerFormat(AnswerFormat answerFormat)
answerFormat
- the answer format for this question stepgetAnswerFormat()
public java.lang.String getPlaceholder()
For numeric and text-based answers, the placeholder content is displayed in the text field or text area when an answer has not yet been entered.
public void setPlaceholder(java.lang.String placeholder)
For numeric and text-based answers, the placeholder content is displayed in the text field or text area when an answer has not yet been entered.
placeholder
- the placeholder string