Beispiel #1
0
  public void next() {
    boolean res;
    test();
    final quizdb quizc = new quizdb(qList.get(i));
    txtques.setText(quizc.getQues());
    opt1.setText(quizc.getOpt1());
    opt2.setText(quizc.getOpt2());
    opt3.setText(quizc.getOpt3());
    opt4.setText(quizc.getOpt4());

    i++;
    if (i >= qList.size()) {
      next.setText("Done");
      next.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {

              try {
                test();

                evaluate();
              } catch (Exception e) {
                Toast.makeText(getApplicationContext(), "Error" + e.getMessage(), Toast.LENGTH_LONG)
                    .show();
              }
            }
          });
    }

    rg.clearCheck();
  }
Beispiel #2
0
 private void setQuestionView() {
   txtQuestion.setText(currentQ.getQuestion());
   rda.setText(currentQ.getOptionA());
   rdb.setText(currentQ.getOptionB());
   rdc.setText(currentQ.getOptionC());
   qid++;
 }
Beispiel #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.science);
    radioButton1 = (RadioButton) findViewById(R.id.option1);
    radioButton2 = (RadioButton) findViewById(R.id.option2);
    radioButton3 = (RadioButton) findViewById(R.id.option3);
    radioButton4 = (RadioButton) findViewById(R.id.option4);
    toasttext = (TextView) findViewById(R.id.toasttext);
    question = (TextView) findViewById(R.id.question);
    rgroup = (RadioGroup) findViewById(R.id.rgroup);
    result1 = (TextView) findViewById(R.id.result1);
    next = (Button) findViewById(R.id.next);
    next.setOnClickListener(this);
    finish = (Button) findViewById(R.id.finish);
    finish.setOnClickListener(this);

    data = new EnterData();
    gt = new GetData();
    data = gt.getDataForScience();
    String option1 = data.getOption1().toString();
    String option2 = data.getOption2().toString();
    String option3 = data.getOption3().toString();
    String option4 = data.getOption4().toString();
    answer = data.getAnswer().toString();

    question.setText(data.getQuestion().toString());
    radioButton1.setText(option1);
    radioButton2.setText(option2);
    radioButton3.setText(option3);
    radioButton4.setText(option4);
  }
 private void loadUserRelation(int relation) {
   switch (relation) {
     case User.RELATION_TYPE_BOTH:
       mRelation.setCompoundDrawablesWithIntrinsicBounds(
           R.drawable.widget_bar_relation_del, 0, 0, 0);
       mRelation.setText("取消互粉");
       break;
     case User.RELATION_TYPE_FANS_HIM:
       mRelation.setCompoundDrawablesWithIntrinsicBounds(
           R.drawable.widget_bar_relation_del, 0, 0, 0);
       mRelation.setText("取消关注");
       break;
     case User.RELATION_TYPE_FANS_ME:
       mRelation.setCompoundDrawablesWithIntrinsicBounds(
           R.drawable.widget_bar_relation_add, 0, 0, 0);
       mRelation.setText("加关注");
       break;
     case User.RELATION_TYPE_NULL:
       mRelation.setCompoundDrawablesWithIntrinsicBounds(
           R.drawable.widget_bar_relation_add, 0, 0, 0);
       mRelation.setText("加关注");
       break;
   }
   if (relation > 0) mRelation.setOnClickListener(relationClickListener);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    idView = (TextView) findViewById(R.id.ques_1);
    choice1 = (RadioButton) findViewById(R.id.choice1);
    choice2 = (RadioButton) findViewById(R.id.choice2);
    choice3 = (RadioButton) findViewById(R.id.choice3);
    choice4 = (RadioButton) findViewById(R.id.choice4);

    // loop for putting the questions inside the database ...

    for (i = 0; i < questions.length && i < answers.length; i++) {
      Questions question_inside_database = new Questions(questions[i], answers[i]);
      dbHandler.addQuestion(question_inside_database);
    }

    if (question_counter == 0) {
      Questions question = dbHandler.findQuestion(questions[0]);
      if (question != null) {
        idView.setText(String.valueOf(question.getQuestionName()));
        choice1.setText(options_1[0]);
        choice2.setText(options_1[1]);
        choice3.setText(options_1[2]);
        choice4.setText(options_1[3]);
      }
    }
  }
  /**
   * this function get called to update the radio buttons and text based on if the device is
   * connected/streaming/logging
   */
  private void updateInterface() {
    String
        middleword; // this string is either empty or contains the word 'not', used the change
                    // "Device is Connected" to "Device is not Connected"

    if (serviceshim != null) {
      // if we are not currently trying to connect then we will update via this method
      if (!TRYING_TO_CONNECT) { //
        middleword = (isDeviceConnected()) ? "" : "not ";
        isdeviceconnected.setText("  Device is " + middleword + "Connected");
        isdeviceconnected.setChecked(isDeviceConnected());

        middleword = (isDeviceStreaming()) ? "" : "not ";
        isdevicestreaming.setText("  Device is " + middleword + "Streaming");
        isdevicestreaming.setChecked(isDeviceStreaming());

        middleword = (isDeviceLogging()) ? "" : "not ";
        isdevicelogging.setText("  Device is " + middleword + "Logging");
        isdevicelogging.setChecked(isDeviceLogging());
      } else {
        // else we are currently trying to connect a shimmer in the background and we will inform
        // the user of such
        isdeviceconnected.setText("  Connecting Device...");
        isdeviceconnected.setChecked(false);
      }
    } // end if serviceshim not null
    else
      Log.d(
          logName,
          "ShimmerDevicesMenu: ShimmerService came back null when trying to updateInterface()");
  } // end function updateInterface()
 /** 初始化单选按钮组 */
 public void initRadioGroup() {
   baoRadioGroup = (RadioGroup) findViewById(R.id.buy_join_radiogroup_baodi);
   for (int i = 0; i < baoTitle.length; i++) {
     RadioButton radio = new RadioButton(this);
     radio.setText(baoTitle[i]);
     radio.setTextColor(Color.BLACK);
     radio.setTextSize(13);
     radio.setId(i);
     radio.setButtonDrawable(R.drawable.radio_select);
     radio.setPadding(Constants.PADDING, 0, 10, 0);
     baoRadioGroup.addView(radio);
   }
   baoRadioGroup.setOnCheckedChangeListener(this);
   baoRadioGroup.check(1);
   openRadioGroup = (RadioGroup) findViewById(R.id.buy_join_radiogroup_open);
   for (int i = 0; i < openTitle.length; i++) {
     RadioButton radio = new RadioButton(this);
     radio.setText(openTitle[i]);
     radio.setTextColor(Color.BLACK);
     radio.setTextSize(13);
     radio.setId(i);
     radio.setButtonDrawable(R.drawable.radio_select);
     radio.setPadding(Constants.PADDING, 0, 10, 0);
     openRadioGroup.addView(radio);
   }
   openRadioGroup.setOnCheckedChangeListener(this);
   openRadioGroup.check(0);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_payment);

    clazz = (ClassInfoBean) getIntent().getExtras().getSerializable("CLAZZ");
    if (clazz == null) {
      finish();
    }

    setTitle(R.string.title_clazz_payment);
    ((Button) findViewById(R.id.back))
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                finish();
              }
            });
    mTab1 = (RadioButton) findViewById(R.id.radio1);
    mTab2 = (RadioButton) findViewById(R.id.radio2);
    mTab1.setText("创建缴费");
    mTab2.setText("已建缴费");
    mContainer = (FrameLayout) findViewById(R.id.content);
    mTab1.setOnCheckedChangeListener(this);
    mTab2.setOnCheckedChangeListener(this);
    mTab1.performClick();
  }
  /** The set up of one player event dialog. */
  private void onePlayerEventDialogSetup() {

    team1EventRBN = (RadioButton) onePlayerEventDG.findViewById(R.id.team1SelEvent);
    team2EventRBN = (RadioButton) onePlayerEventDG.findViewById(R.id.team2SelEvent);
    team1EventRBN.setText(team1);
    team2EventRBN.setText(team2);
    team1EventRBN.setChecked(true);

    // Team1 text view and input set up.
    playerAdapter = new ArrayAdapter<>(this, R.layout.list_team, players);
    playerOneNameEventAutoTV =
        (AutoCompleteTextView) onePlayerEventDG.findViewById(R.id.player1EventNameAUTOTV);
    playerOneNameEventAutoTV.setAdapter(playerAdapter);

    // Submit Match Event button.
    BootstrapButton createMatchEventBN =
        (BootstrapButton) onePlayerEventDG.findViewById(R.id.createMatchEventBN);
    createMatchEventBN.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {

            // Get team selected from radio buttons.
            if (team1EventRBN.isChecked()) eventTeamSel = team1EventRBN.getText().toString();
            else if (team2EventRBN.isChecked()) eventTeamSel = team2EventRBN.getText().toString();

            // Set player event happened to.
            eventPlayer1Name = playerOneNameEventAutoTV.getText().toString().trim();

            // Create match event and store it in list of match events.
            MatchEvent matchEvent =
                new MatchEvent(eventTime, eventType, eventPlayer1Name, eventTeamSel);

            // If Goal event update GUI to display new score.
            if (getString(R.string.event_goal).equals(eventType)) updateGoalScore(eventTeamSel);

            // If point event update GUI to display new score.
            if (getString(R.string.event_point).equals(eventType)) updatePointScore(eventTeamSel);

            // Add match event to list of match events so far.
            matchEvents.add(matchEvent);
            matchInfo += matchEvent.toString();
            matchInfoTV.setText(matchInfo);
            playerOneNameEventAutoTV.setText("");
            onePlayerEventDG.hide();
          }
        });

    // Hide Match Event button.
    BootstrapButton hideMatchEventBN =
        (BootstrapButton) onePlayerEventDG.findViewById(R.id.hideMatchEventBN);
    hideMatchEventBN.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            playerOneNameEventAutoTV.setText("");
            onePlayerEventDG.hide();
          }
        });
  }
Beispiel #10
0
 public void intialise() {
   final quizdb quizc = new quizdb(qList.get(0));
   txtques.setText(quizc.getQues());
   opt1.setText(quizc.getOpt1());
   opt2.setText(quizc.getOpt2());
   opt3.setText(quizc.getOpt3());
   opt4.setText(quizc.getOpt4());
 }
Beispiel #11
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fg_jeux, container, false);

    activity = (MainActivity) getActivity();

    partie = Partie.getInstance();

    etPoint = (EditText) v.findViewById(R.id.et_nombre_point);

    rdTeamPris = (RadioGroup) v.findViewById(R.id.radio_team_pris);
    RadioButton rdBtnTeam1Pris = (RadioButton) v.findViewById(R.id.radio_team1);
    RadioButton rdBtnTeam2Pris = (RadioButton) v.findViewById(R.id.radio_team2);

    rdTeamPrisBeloteRebelote = (RadioGroup) v.findViewById(R.id.radio_team_belote_rebelote);
    RadioButton rdBtnTeam1BR = (RadioButton) v.findViewById(R.id.radio_team_br1);
    RadioButton rdBtnTeam2BR = (RadioButton) v.findViewById(R.id.radio_team_br2);

    String nomT1 = partie.getTeam1().nom;
    if (nomT1 != null && nomT1.length() > 0) {
      rdBtnTeam1Pris.setText(nomT1);
      rdBtnTeam1BR.setText(nomT1);
    }

    String nomT2 = partie.getTeam2().nom;
    if (nomT2 != null && nomT2.length() > 0) {
      rdBtnTeam2Pris.setText(nomT2);
      rdBtnTeam2BR.setText(nomT2);
    }

    cbBeloteRebelote = (CheckBox) v.findViewById(R.id.cb_belote_rebelote);

    cbBeloteRebelote.setText(getString(R.string.no));
    cbBeloteRebelote.setChecked(false);

    cbBeloteRebelote.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
              cbBeloteRebelote.setText(getString(R.string.yes));
              rdTeamPrisBeloteRebelote.setVisibility(View.VISIBLE);
            } else {
              cbBeloteRebelote.setText(getString(R.string.no));
              rdTeamPrisBeloteRebelote.setVisibility(View.INVISIBLE);
            }
          }
        });

    Button btnValider = (Button) v.findViewById(R.id.btn_valider);
    Button btnQuit = (Button) v.findViewById(R.id.btn_quit);

    btnValider.setOnClickListener(this);
    btnQuit.setOnClickListener(this);

    return v;
  }
 private void setupRadioGroup() {
   radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
   radioButton1 = (RadioButton) findViewById(R.id.radioButton1);
   radioButton2 = (RadioButton) findViewById(R.id.radioButton2);
   radioButton3 = (RadioButton) findViewById(R.id.radioButton3);
   radioButton1.setText(INITIAL_TEXT + " ... 1");
   radioButton2.setText(INITIAL_TEXT + " ... 2");
   radioButton3.setText(INITIAL_TEXT + " ... 3");
 }
  private void showQuestion(int qIndex, boolean review) {
    try {
      JSONObject aQues = QuizFunActivity.getQuesList().getJSONObject(qIndex);
      String quesValue = aQues.getString("Question");
      if (correctAns[qIndex] == -1) {
        String correctAnsStr = aQues.getString("CorrectAnswer");
        correctAns[qIndex] = Integer.parseInt(correctAnsStr);
      }

      question.setText(quesValue.toCharArray(), 0, quesValue.length());
      answers.check(-1);
      answer1.setTextColor(Color.WHITE);
      answer2.setTextColor(Color.WHITE);
      answer3.setTextColor(Color.WHITE);
      answer4.setTextColor(Color.WHITE);
      JSONArray ansList = aQues.getJSONArray("Answers");
      String aAns = ansList.getJSONObject(0).getString("Answer");
      answer1.setText(aAns.toCharArray(), 0, aAns.length());
      aAns = ansList.getJSONObject(1).getString("Answer");
      answer2.setText(aAns.toCharArray(), 0, aAns.length());
      aAns = ansList.getJSONObject(2).getString("Answer");
      answer3.setText(aAns.toCharArray(), 0, aAns.length());
      aAns = ansList.getJSONObject(3).getString("Answer");
      answer4.setText(aAns.toCharArray(), 0, aAns.length());
      Log.d("", selected[qIndex] + "");
      if (selected[qIndex] == 0) answers.check(R.id.a0);
      if (selected[qIndex] == 1) answers.check(R.id.a1);
      if (selected[qIndex] == 2) answers.check(R.id.a2);
      if (selected[qIndex] == 3) answers.check(R.id.a3);

      setScoreTitle();
      if (quesIndex == (QuizFunActivity.getQuesList().length() - 1)) next.setEnabled(false);

      if (quesIndex == 0) prev.setEnabled(false);

      if (quesIndex > 0) prev.setEnabled(true);

      if (quesIndex < (QuizFunActivity.getQuesList().length() - 1)) next.setEnabled(true);

      if (review) {
        Log.d("review", selected[qIndex] + "" + correctAns[qIndex]);
        ;
        if (selected[qIndex] != correctAns[qIndex]) {
          if (selected[qIndex] == 0) answer1.setTextColor(Color.RED);
          if (selected[qIndex] == 1) answer2.setTextColor(Color.RED);
          if (selected[qIndex] == 2) answer3.setTextColor(Color.RED);
          if (selected[qIndex] == 3) answer4.setTextColor(Color.RED);
        }
        if (correctAns[qIndex] == 0) answer1.setTextColor(Color.GREEN);
        if (correctAns[qIndex] == 1) answer2.setTextColor(Color.GREEN);
        if (correctAns[qIndex] == 2) answer3.setTextColor(Color.GREEN);
        if (correctAns[qIndex] == 3) answer4.setTextColor(Color.GREEN);
      }
    } catch (Exception e) {
      Log.e(this.getClass().toString(), e.getMessage(), e.getCause());
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_item);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      getSupportActionBar().setDisplayShowHomeEnabled(true);
      actionBar.setLogo(R.mipmap.cp_logo);
      getSupportActionBar().setDisplayUseLogoEnabled(true);
    }
    EditText editItem = (EditText) findViewById(R.id.etEditItem);
    editItem.setText(getIntent().getStringExtra("itemText"));
    editItem.setSelection(editItem.getText().length());

    SimpleDateFormat date = new SimpleDateFormat("MM/d/yyyy");
    dueDate = getIntent().getLongExtra("dueDate", System.currentTimeMillis());
    Button dueDateText = (Button) findViewById(R.id.btCalendar);
    dueDateText.setText(date.format(new Date(dueDate)));

    RadioButton radioButton3 = (RadioButton) findViewById(R.id.rbPriority3);
    radioButton3.setText(prefs.getString("priority_default", "Just do it"));

    RadioButton radioButton2 = (RadioButton) findViewById(R.id.rbPriority2);
    radioButton2.setText(prefs.getString("priority_high", "Get it done!"));

    RadioButton radioButton1 = (RadioButton) findViewById(R.id.rbPriority1);
    radioButton1.setText(prefs.getString("priority_highest", "Life Matter"));

    itemPriority = Integer.parseInt(getIntent().getStringExtra("priority"));
    switch (itemPriority) {
      case CommonConstants.STANDARD_PRIORITY:
        {
          radioButton3.performClick();
          editItem.setTextColor(editItem.getResources().getColor(R.color.standard_priority));
          break;
        }
      case CommonConstants.ELEVATED_PRIORITY:
        {
          radioButton2.performClick();
          editItem.setTextColor(editItem.getResources().getColor(R.color.elevated_priority));
          break;
        }
      case CommonConstants.HIGH_PRIORITY:
        {
          radioButton1.performClick();
          editItem.setTextColor(editItem.getResources().getColor(R.color.high_priority));
          break;
        }
    }
  }
  public void submit(View view) {

    question_counter++;
    option_counter++;

    result = (TextView) findViewById(R.id.result);
    result.setText("Your Score is " + counter);
    if (question_counter < 3) {
      Questions question = dbHandler.findQuestion(questions[question_counter]);
      if (question != null) {
        idView.setText(String.valueOf(question.getQuestionName()));

      } else {
        idView.setText("End of questions . Your Score is " + counter);
      }
    }
    if (option_counter == 1) {
      choice1.setText(options_2[0]);
      choice2.setText(options_2[1]);
      choice3.setText(options_2[2]);
      choice4.setText(options_2[3]);
    } else if (option_counter == 2) {

      choice1.setText(option_3[0]);
      choice2.setText(option_3[1]);
      choice3.setText(option_3[2]);
      choice4.setText(option_3[3]);
    }
  }
  private void init(Context context, View contentview, String[] items) {
    /** 用数据初始化ui */
    radioGroup = (RadioGroup) contentview.findViewById(R.id.filter_layout);
    radioGroup.clearCheck();
    if (items == null) return;
    for (int i = 0; i < items.length; i++) {

      RadioButton radioButton =
          (RadioButton) LayoutInflater.from(context).inflate(R.layout.line_popupwindow_rbt, null);
      radioButton.setId(rbtIds[i]);
      radioButton.setText(items[i]);

      radioGroup.addView(radioButton, -1, radioGroup.getLayoutParams());

      if (items[i].equals(outCbx.getText())) {
        outCbx.setTag(i);
        radioButton.setChecked(true);
      }
    }
    radioGroup.setOnCheckedChangeListener(
        new RadioGroup.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(RadioGroup group, int checkedId) {
            dismiss();
          }
        });
  }
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  @Override
  public ComponentAdapter<RadioGroup> createComponent(ConfigRadio configRadio) {
    int[][] states =
        new int[][] {
          new int[] {android.R.attr.state_enabled}, // enabled
          new int[] {-android.R.attr.state_enabled}, // disabled
          new int[] {-android.R.attr.state_checked}, // unchecked
          new int[] {android.R.attr.state_pressed} // pressed
        };

    int[] colors = new int[] {Color.BLACK, Color.RED, Color.GREEN, Color.BLUE};

    ColorStateList myList = new ColorStateList(states, colors);

    RadioGroup group = new RadioGroup(AndroidConfiguration.getInstance().getCurrentContext());
    Map<String, RadioButton> buttons = new HashMap<String, RadioButton>();
    for (Object value : configRadio.getValues()) {
      RadioButton radio = new RadioButton(AndroidConfiguration.getInstance().getCurrentContext());
      radio.setText(value.toString());
      radio.setTextColor(Color.BLACK);
      buttons.put(value.toString(), radio);
      radio.setButtonTintList(myList);
      group.addView(radio);
    }
    return new AndroidRadioAdapter(group, buttons);
  }
  private void initializeViews() {
    WindowManager.LayoutParams lpWindow = new WindowManager.LayoutParams();
    lpWindow.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    lpWindow.dimAmount = 0.8f;
    getWindow().setAttributes(lpWindow);

    setContentView(R.layout.select_box_dialog);

    Button.class.cast(findViewById(R.id.confirm)).setOnClickListener(confirmClickListener);

    RadioGroup select_group = RadioGroup.class.cast(findViewById(R.id.select_group));
    select_group.setOnCheckedChangeListener(radio_group_listener);
    for (Map.Entry<Object, String> elem : select_list.entrySet()) {
      RadioButton radio_button = new RadioButton(this.getContext());
      radio_button.setButtonDrawable(R.drawable.ui_radio_blue);
      radio_button.setText(elem.getValue());
      radio_button.setId(ServerList.ServerInfo.ServerName.class.cast(elem.getKey()).ordinal());
      if (checked_index == ServerList.ServerInfo.ServerName.class.cast(elem.getKey()).ordinal()) {
        radio_button.setChecked(true);
      }
      select_group.addView(radio_button);
    }
    TextView.class.cast(findViewById(R.id.message)).setText(this.message);
    if (this.message.equals("")) {
      TextView.class.cast(findViewById(R.id.message)).setVisibility(View.GONE);
    }
  }
Beispiel #19
0
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case AppConstants.OK:
              Bundle bundle = msg.getData();

              ProCodeArr = bundle.getStringArray(columns[0]);
              ProNameArr = bundle.getStringArray(columns[1]);
              projectsMap = new HashMap<String, String>();

              rgProInfo = (RadioGroup) findViewById(R.id.rgProjects);

              RadioButton rb = null;

              for (int i = 0; i < ProNameArr.length; i++) {
                rb = new RadioButton(rgProInfo.getContext());

                rb.setText(ProNameArr[i]);
                rb.setTextSize(20);
                // 选中其次选中的数据
                if (ProCodeArr[i].equals(selectedProCode)) {
                  rb.setChecked(true);
                  // 直接点击返回按钮后,将其次选择的数据返回
                  selectedProName = ProNameArr[i];
                }

                rgProInfo.addView(rb);

                projectsMap.put(ProNameArr[i], ProCodeArr[i]);
              }

              dataListLayout.setVisibility(View.VISIBLE);
              break;
            case AppConstants.NG:
              Toast.makeText(
                      appContext,
                      appContext.getString(R.string.error_select_result_zero),
                      Toast.LENGTH_LONG)
                  .show();
              break;
            case AppConstants.ERROR1:
              Toast.makeText(
                      appContext,
                      appContext.getString(R.string.error_network_connected),
                      Toast.LENGTH_LONG)
                  .show();
              break;
            case AppConstants.ERROR2:
              Toast.makeText(
                      appContext, appContext.getString(R.string.system_error), Toast.LENGTH_LONG)
                  .show();
              break;
            default:
              break;
          }

          loadingLayout.setVisibility(View.GONE);
        }
  private void initProblem() {
    right_answer = random();
    wrong_answer = chooseOtherThan(right_answer);

    choices.clear();
    choices.add(right_answer);
    choices.add(wrong_answer);
    Collections.shuffle(choices);

    radioGroup.clearCheck();

    choice1.setText(textFor(choices.get(0)));
    choice2.setText(textFor(choices.get(1)));

    continueButton.setVisibility(View.GONE);
    checkButton.setVisibility(View.VISIBLE);
    checkButton.setEnabled(false);
  }
Beispiel #21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dials);

    schemesLL = (LinearLayout) findViewById(R.id.colors);
    prefs = getSharedPreferences(getString(R.string.prefs_name), MODE_PRIVATE);
    colorSchemes = getResources().getStringArray(R.array.color_schemes);

    // load the color schemes

    OnClickListener ocl =
        new OnClickListener() {
          public void onClick(View v) {
            String sc = (String) v.getTag();
            SharedPreferences.Editor editor = prefs.edit();
            editor.putString("color_scheme", sc);
            editor.commit();
          }
        };

    // color oscillator

    colorOscillator =
        new Runnable() {
          public void run() {
            nyxView.setDuration(OSC_PERIOD);
            nyxView.setTimingFunction(OSC_TIMING);
            nyxView.setBaseColor(colors[(++curColor) % 2]);
            nyxView.postDelayed(this, OSC_PERIOD);
          }
        };

    // construct the list of color schemes

    for (String cs : colorSchemes) {
      View v = getLayoutInflater().inflate(R.layout.color_scheme_item, null);
      RadioButton rb = (RadioButton) v.findViewById(R.id.color_scheme_name);
      rb.setTag(cs);
      rb.setText(
          getString(
              getResources().getIdentifier("color_scheme_" + cs, "string", getPackageName())));

      rb.setOnClickListener(ocl);
      schemesLL.addView(v);
    }

    nyxView = (NyxView) findViewById(R.id.nyxview);
    nyxView.setDuration(0);
    nyxView.setComposition(Util.loadCompositionRes(this, R.string.default_composition));
    nyxView.setText(getString(R.string.configure_me));
    nyxView.setTextSize(
        getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
            ? 1.0
            : 1.5);
    nyxView.rerender();
  }
 private static View createSwitch(
     @NonNull LayoutInflater inflater,
     @NonNull ViewGroup parent,
     @NonNull FormField field,
     @NonNull String value,
     @NonNull String instructions,
     boolean readOnly,
     @NonNull final SwitchListener switchListener) {
   final View view = inflater.inflate(R.layout.edit_user_profile_switch, parent, false);
   ((TextView) view.findViewById(R.id.label)).setText(field.getLabel());
   ((TextView) view.findViewById(R.id.instructions)).setText(instructions);
   final RadioGroup group = ((RadioGroup) view.findViewById(R.id.options));
   {
     final RadioButton optionOne = ((RadioButton) view.findViewById(R.id.option_one));
     final RadioButton optionTwo = ((RadioButton) view.findViewById(R.id.option_two));
     optionOne.setText(field.getOptions().getValues().get(0).getName());
     optionOne.setTag(field.getOptions().getValues().get(0).getValue());
     optionTwo.setText(field.getOptions().getValues().get(1).getName());
     optionTwo.setTag(field.getOptions().getValues().get(1).getValue());
   }
   for (int i = 0; i < group.getChildCount(); i++) {
     final View child = group.getChildAt(i);
     child.setEnabled(!readOnly);
     if (child.getTag().equals(value)) {
       group.check(child.getId());
       break;
     }
   }
   if (readOnly) {
     group.setEnabled(false);
     view.setBackgroundColor(view.getResources().getColor(R.color.edx_grayscale_neutral_x_light));
   } else {
     group.setOnCheckedChangeListener(
         new RadioGroup.OnCheckedChangeListener() {
           @Override
           public void onCheckedChanged(RadioGroup group, int checkedId) {
             switchListener.onSwitch((String) group.findViewById(checkedId).getTag());
           }
         });
   }
   parent.addView(view);
   return view;
 }
Beispiel #23
0
  public void generate() {
    radioGroup.removeAllViews();

    for (int i = 0; i < strings.size(); i++) {
      RadioButton b = new RadioButton(getContext());
      b.setText(strings.get(i));
      b.setId(values.get(i));
      radioGroup.addView(b);
    }
  }
Beispiel #24
0
  private void updateContent(int index) {
    final TextView question = (TextView) findViewById(R.id.question);
    RadioButton choice1 = (RadioButton) findViewById(R.id.choice1);
    RadioButton choice2 = (RadioButton) findViewById(R.id.choice2);
    RadioButton choice3 = (RadioButton) findViewById(R.id.choice3);
    RadioButton choice4 = (RadioButton) findViewById(R.id.choice4);

    class ImageHandler implements Html.ImageGetter {
      @Override
      public Drawable getDrawable(String source) {
        Drawable pics = null;
        try {
          pics = Drawable.createFromStream(getApplicationContext().getAssets().open(source), null);
          int width = question.getWidth();
          int height = pics.getIntrinsicHeight() * width / pics.getIntrinsicWidth();
          pics.setBounds(0, 0, width, height);
        } catch (IOException e) {
          e.printStackTrace();
        }
        return pics;
      }
    }

    // Set content view
    Soal soal = soals.get(index);
    question.setText(Html.fromHtml(soal.getQuestion(), new ImageHandler(), null));
    choice1.setText(Html.fromHtml(soal.getChoices().get(0), new ImageHandler(), null));
    choice2.setText(Html.fromHtml(soal.getChoices().get(1), new ImageHandler(), null));
    choice3.setText(Html.fromHtml(soal.getChoices().get(2), new ImageHandler(), null));
    choice4.setText(Html.fromHtml(soal.getChoices().get(3), new ImageHandler(), null));

    // Set checked radio
    Integer choice = opts[index];
    RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
    while (!optionChecking.tryLock()) {}
    optionChecking.lock();
    if (choice != null) {
      radioGroup.check(radioGroup.getChildAt(choice).getId());
    } else {
      radioGroup.clearCheck();
    }
    optionChecking.unlock();
  }
  private void resetKeyword() {
    // reset new keyword datas from keywordTABLE database
    String sql = "select keyword_one ,keyword_two, keyword_three from keywordTABLE";
    Cursor cursor = helper.db.rawQuery(sql, null);

    int recordCount = cursor.getCount();
    for (int i = 0; i < recordCount; i++) {
      cursor.moveToNext();
      k1 = cursor.getString(0);
      k2 = cursor.getString(1);
      k3 = cursor.getString(2);
      Log.i("AhReum", "keyword : " + k1 + "   " + "keyword1 : " + k2 + "   keyword2 : " + k3); //
    }

    radio1.setText(k1);
    radio2.setText(k2);
    radio3.setText(k3);
    memo = k1; // 선택된걸로 바꿔야함
    editText.setText(memo + BookmarkCount);
  }
Beispiel #26
0
 public void initTopButton() {
   for (int i = 0; i < topTitle.length; i++) {
     RadioButton radio = new RadioButton(this);
     radio.setText(topTitle[i]);
     radio.setTextColor(Color.BLACK);
     radio.setTextSize(13);
     radio.setId(i);
     radio.setButtonDrawable(R.drawable.radio_select);
     radio.setPadding(Constants.PADDING, 0, 10, 0);
     topButton.addView(radio);
   }
 }
 private void m10904p() {
   af afVar = new af(this, 2131427471);
   afVar.m3606a((CharSequence) "Send message seen report");
   View inflate = getLayoutInflater().inflate(2130968699, null);
   RadioGroup radioGroup = (RadioGroup) inflate.findViewById(2131689763);
   RadioButton radioButton = (RadioButton) inflate.findViewById(2131689765);
   ((RadioButton) inflate.findViewById(2131689764)).setText(getString(2131230900));
   radioButton.setText(getString(2131230899));
   afVar.m3609b(inflate);
   afVar.m3611b(getString(2131230814), null);
   afVar.m3607a(getString(2131230921), new C2545b(this, radioGroup));
   afVar.m3612c();
 }
Beispiel #28
0
  @Override
  public void onClick(View view) {

    if ((view.getId() == R.id.next)) {
      radioButton1.setEnabled(true);
      radioButton2.setEnabled(true);
      radioButton3.setEnabled(true);
      radioButton4.setEnabled(true);

      radioButton1.setChecked(false);
      radioButton2.setChecked(false);
      radioButton3.setChecked(false);
      radioButton4.setChecked(false);
      data = new EnterData();
      gt = new GetData();
      data = gt.getDataForScience();
      String option1 = data.getOption1().toString();
      String option2 = data.getOption2().toString();
      String option3 = data.getOption3().toString();
      String option4 = data.getOption4().toString();
      answer = data.getAnswer().toString();

      question.setText(data.getQuestion().toString());
      radioButton1.setText(option1);
      radioButton2.setText(option2);
      radioButton3.setText(option3);
      radioButton4.setText(option4);
      // Toast.makeText(this, "Total Right Answer"+r+"Total Worng Answer"+w, 2).show();

    }

    if (view.getId() == R.id.finish) {
      Intent intent = new Intent();
      intent.setClass(this, MainActivity.class);
      Toast.makeText(this, "Start next activity", 2).show();
      startActivity(intent);
    }
  }
  public void populateRadioGroup() {
    if (radioGroup == null || populateRadioGroup == false) return;

    for (int i = 0; i < groupList.length; i++) {
      RadioButton radioButton = new RadioButton(context);
      radioButton.setText(groupList[i].name);
      radioButton.setId(groupList[i].grpid);
      radioButton.setTextColor(R.color.text_dark_green);

      radioGroup.addView(radioButton);
    }

    radioGroup.invalidate();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);

    /*Test test =data.getTest();
    TextView textWording=(TextView)findViewById(R.id.pregunta_test);
    textWording.setText(test.getWording());
    RadioGroup group=(RadioGroup)findViewById(R.id.test_choices);
    int i=0;
    for(Test.Choice choice : test.getChoices()){
        RadioButton radio =new RadioButton(this);
        radio.setText(choice.getWording());
        group.addView(radio);
        if(choice.iscorrect())
            correct=i;
        i++;
    }*/

    /** *************************ANTES DE COMUNICACIONES****************** */
    TextView pregunta = (TextView) findViewById(R.id.pregunta_test);
    Button enviar = (Button) findViewById(R.id.button_send_test);
    RadioGroup respuestas = (RadioGroup) findViewById(R.id.test_choices);

    pregunta.setText(R.string.pregunta_test);

    String[] opciones = {
      "Versión de la aplicación",
      "Listado de componentes de la aplicación",
      "Opciones del menú de ajustes",
      "Nivel mínimo de la API Android requerida",
      "Nombre del paquete java de la aplicación"
    };

    int i;

    for (i = 0; i < opciones.length; i++) {
      RadioButton radio = new RadioButton(this);
      radio.setText(opciones[i]);
      radio.setId(i);
      radio.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              findViewById(R.id.button_send_test).setVisibility(View.VISIBLE);
            }
          });
      respuestas.addView(radio);
    } /**/
  }