Search in sources :

Example 1 with OptionsQuizAdapter

use of com.google.samples.apps.topeka.adapter.OptionsQuizAdapter in project android-topeka by googlesamples.

the class SelectItemQuizView method createQuizContentView.

@Override
protected View createQuizContentView() {
    Context context = getContext();
    mListView = new ListView(context);
    mListView.setDivider(null);
    mListView.setSelector(R.drawable.selector_button);
    mListView.setAdapter(new OptionsQuizAdapter(getQuiz().getOptions(), R.layout.item_answer_start, context, true));
    mListView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            allowAnswer();
            toggleAnswerFor(position);
        }
    });
    return mListView;
}
Also used : Context(android.content.Context) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) OptionsQuizAdapter(com.google.samples.apps.topeka.adapter.OptionsQuizAdapter) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint)

Example 2 with OptionsQuizAdapter

use of com.google.samples.apps.topeka.adapter.OptionsQuizAdapter in project android-topeka by googlesamples.

the class ToggleTranslateQuizView method createQuizContentView.

@Override
protected View createQuizContentView() {
    mListView = new ListView(getContext());
    mListView.setDivider(null);
    mListView.setSelector(R.drawable.selector_button);
    mListView.setAdapter(new OptionsQuizAdapter(getQuiz().getReadableOptions(), R.layout.item_answer));
    mListView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            toggleAnswerFor(position);
            if (view instanceof CompoundButton) {
                ((CompoundButton) view).setChecked(mAnswers[position]);
            }
            allowAnswer();
        }
    });
    return mListView;
}
Also used : AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) OptionsQuizAdapter(com.google.samples.apps.topeka.adapter.OptionsQuizAdapter) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) CompoundButton(android.widget.CompoundButton)

Example 3 with OptionsQuizAdapter

use of com.google.samples.apps.topeka.adapter.OptionsQuizAdapter in project android-topeka by googlesamples.

the class FourQuarterQuizView method createQuizContentView.

@Override
protected View createQuizContentView() {
    mAnswerView = new GridView(getContext());
    mAnswerView.setSelector(R.drawable.selector_button);
    mAnswerView.setNumColumns(2);
    mAnswerView.setAdapter(new OptionsQuizAdapter(getQuiz().getOptions(), R.layout.item_answer));
    mAnswerView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            allowAnswer();
            mAnswered = position;
        }
    });
    return mAnswerView;
}
Also used : OptionsQuizAdapter(com.google.samples.apps.topeka.adapter.OptionsQuizAdapter) AdapterView(android.widget.AdapterView) GridView(android.widget.GridView) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) SuppressLint(android.annotation.SuppressLint)

Example 4 with OptionsQuizAdapter

use of com.google.samples.apps.topeka.adapter.OptionsQuizAdapter in project android-topeka by googlesamples.

the class MultiSelectQuizView method createQuizContentView.

@Override
protected View createQuizContentView() {
    mListView = new ListView(getContext());
    mListView.setAdapter(new OptionsQuizAdapter(getQuiz().getOptions(), android.R.layout.simple_list_item_multiple_choice));
    mListView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
    mListView.setItemsCanFocus(false);
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            allowAnswer();
        }
    });
    return mListView;
}
Also used : AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) OptionsQuizAdapter(com.google.samples.apps.topeka.adapter.OptionsQuizAdapter) AdapterView(android.widget.AdapterView) View(android.view.View) AbsListView(android.widget.AbsListView) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)4 View (android.view.View)4 AdapterView (android.widget.AdapterView)4 OptionsQuizAdapter (com.google.samples.apps.topeka.adapter.OptionsQuizAdapter)4 AbsListView (android.widget.AbsListView)3 ListView (android.widget.ListView)3 Context (android.content.Context)1 CompoundButton (android.widget.CompoundButton)1 GridView (android.widget.GridView)1