Esempio n. 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_setup4);
    mCheck = (CheckBox) findViewById(R.id.cb_protect);

    boolean protect = mPref.getBoolean("protect", false);
    // 当check发生改变时,回掉此方法
    if (protect) {
      mCheck.setText("防盗保护已经开启");
      mCheck.setChecked(true);
    } else {
      mCheck.setText("防盗保护没有开启");
      mCheck.setChecked(false);
    }
    mCheck.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
              mCheck.setText("防盗保护已经开启");
              mPref.edit().putBoolean("protect", true).commit();
            } else {
              mCheck.setText("防盗保护没有开启");
              mPref.edit().putBoolean("protect", false).commit();
            }
          }
        });
  }
Esempio n. 2
0
  private void initUI() {
    cb_box = (CheckBox) findViewById(R.id.cb_box);
    // 1,是否选中状态的回显
    boolean open_security = SpUtil.getBoolean(this, ConstantValue.OPEN_SECURITY, false);
    // 2,根据状态,修改checkbox后续的文字显示
    cb_box.setChecked(open_security);
    if (open_security) {
      cb_box.setText("安全设置已开启");
    } else {
      cb_box.setText("安全设置已关闭");
    }

    //		cb_box.setChecked(!cb_box.isChecked());
    // 3,点击过程中,监听选中状态发生改变过程,
    cb_box.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // 4,isChecked点击后的状态,存储点击后状态
            SpUtil.putBoolean(getApplicationContext(), ConstantValue.OPEN_SECURITY, isChecked);
            // 5,根据开启关闭状态,去修改显示的文字
            if (isChecked) {
              cb_box.setText("安全设置已开启");
            } else {
              cb_box.setText("安全设置已关闭");
            }
          }
        });
  }
Esempio n. 3
0
 private void setRepoSwitchChecked(boolean checked) {
   repoSwitch.setChecked(checked);
   if (checked) {
     repoSwitch.setText(R.string.local_repo_running);
   } else {
     repoSwitch.setText(R.string.touch_to_turn_on_local_repo);
   }
 }
 void enableVibrateControls() {
   boolean overrideSilence = checkboxAlertOverride.isChecked();
   if (overrideSilence) {
     checkboxAlertOverride.setText("");
   } else {
     checkboxAlertOverride.setText(
         "Warning, no alert will be played at phone silent/vibrate mode!!!");
   }
 }
 private void setupCheckBoxes() {
   checkBox1 = (CheckBox) findViewById(R.id.checkBox1);
   checkBox2 = (CheckBox) findViewById(R.id.checkBox2);
   checkBox3 = (CheckBox) findViewById(R.id.checkBox3);
   checkBox1.setText(INITIAL_TEXT + " ... 1");
   checkBox2.setText(INITIAL_TEXT + " ... 2");
   checkBox3.setText(INITIAL_TEXT + " ... 3");
   checkBox2.setChecked(true);
 }
Esempio n. 6
0
 @Override
 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
   if (isChecked) {
     wifiManager.setWifiEnabled(true);
     chkOpenCloseWifiBox.setText("Wifi已开启");
   } else {
     wifiManager.setWifiEnabled(false);
     chkOpenCloseWifiBox.setText("Wifi已关闭");
   }
 }
Esempio n. 7
0
  public SelectModeView(Context context, AttributeSet attrs) {
    super(context, attrs);
    initView(); // 初始化界面

    String twoText =
        attrs.getAttributeValue(
            "http://schemas.android.com/apk/res/" + getContext().getPackageName(), "twotext");
    String oneText =
        attrs.getAttributeValue(
            "http://schemas.android.com/apk/res/" + getContext().getPackageName(), "onetext");

    cb_sms.setText(oneText);
    cb_phone.setText(twoText);
  }
Esempio n. 8
0
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    View view = convertView;
    if (view == null) {
      LayoutInflater inflater =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      view = inflater.inflate(R.layout.custom_listview_element, null);
    }
    TextView listItemText = (TextView) view.findViewById(R.id.list_item_string);
    listItemText.setText(list.get(position).toString());

    /** Takes the current item converts to string and puts in the current order in the list. */
    final CheckBox checkbox = (CheckBox) view.findViewById(R.id.doneCheckBox);
    final Button button = (Button) view.findViewById(R.id.button);
    final int Position = position;
    if (list.get(position).isDone()) {
      checkbox.setChecked(true);
      checkbox.setText("Done");

    } else {
      checkbox.setChecked(false);
      checkbox.setText("Undone");
    }

    button.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            list.remove(Position);
            notifyDataSetChanged();
            dataFromFile = readActivitiesFromFile();
            dataFromFile.remove(position);
            writeActivityToFile(dataFromFile);
          }
        });

    checkbox.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            String text = "";
            // list.get(Position).setDone(checkbox.isChecked());//Changes the value of the activity
            // object's boolean
            if (checkbox.isChecked()) checkbox.setText("Done");
            else checkbox.setText("Undone");
            // perform logic
          }
        });
    return view;
  }
Esempio n. 9
0
  public void performUpdate() {
    controlLayout.removeAllViews();

    for (iotnode n : foobar.getNodes()) {
      CheckBox cb = new CheckBox(this);
      n.index = foobar.getNodes().indexOf(n);
      cb.setText(n.toString());
      cb.setChecked(n.getState());
      final int idx = n.index;
      cb.setOnCheckedChangeListener(
          new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              // foobar.setState(idx, isChecked);
              Log.d("box", "" + idx);
              try {
                foobar.setState(idx, isChecked);
                foobar.pushState();
              } catch (Exception e) {
                e.printStackTrace();
              }
              Toast.makeText(getApplicationContext(), buttonView.getText(), Toast.LENGTH_SHORT)
                  .show();
            }
          });
      controlLayout.addView(cb);
    }
  }
Esempio n. 10
0
  /** Returns the view for a specific item on the list */
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View row = convertView;

    final ToDoItem currentItem = getItem(position);

    if (row == null) {
      LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
      row = inflater.inflate(mLayoutResourceId, parent, false);
    }

    row.setTag(currentItem);
    final CheckBox checkBox = (CheckBox) row.findViewById(R.id.checkToDoItem);
    checkBox.setText(currentItem.getText());
    checkBox.setChecked(false);
    checkBox.setEnabled(true);

    checkBox.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View arg0) {
            if (checkBox.isChecked()) {
              checkBox.setEnabled(false);
              if (mContext instanceof ToDoActivity) {
                ToDoActivity activity = (ToDoActivity) mContext;
                activity.checkItem(currentItem);
              }
            }
          }
        });

    return row;
  }
 @Override
 public Dialog onCreateDialog(Bundle savedInstanceState) {
   final Bundle bundle = getArguments();
   Activity ctx = getActivity();
   AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
   int title = bundle.getInt(KEY_TITLE, 0);
   if (title != 0) {
     builder.setTitle(title);
   }
   builder.setMessage(bundle.getCharSequence(KEY_MESSAGE));
   int checkboxLabel = bundle.getInt(KEY_CHECKBOX_LABEL, 0);
   if (bundle.getString(KEY_PREFKEY) != null || checkboxLabel != 0) {
     //noinspection InflateParams
     View cb = LayoutInflater.from(ctx).inflate(R.layout.checkbox, null);
     checkBox = (CheckBox) cb.findViewById(R.id.checkbox);
     checkBox.setText(
         checkboxLabel != 0 ? checkboxLabel : R.string.confirmation_dialog_dont_show_again);
     builder.setView(cb);
   }
   int positiveLabel = bundle.getInt(KEY_POSITIVE_BUTTON_LABEL);
   int negativeLabel = bundle.getInt(KEY_NEGATIVE_BUTTON_LABEL);
   builder.setPositiveButton(positiveLabel == 0 ? android.R.string.ok : positiveLabel, this);
   builder.setNegativeButton(negativeLabel == 0 ? android.R.string.cancel : negativeLabel, this);
   return builder.create();
 }
Esempio n. 12
0
 @Override
 public void hydrate(final CheckBox checkBox, final PersistedDataBean payload) {
   CheckBoxBean bean = (CheckBoxBean) payload;
   checkBox.setText(bean.text);
   checkBox.setEnabled(bean.enabled);
   checkBox.setVisibility(bean.visibility);
 }
Esempio n. 13
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_check_box_test);
   linearLayout = (LinearLayout) this.findViewById(R.id.layout);
   button = (Button) this.findViewById(R.id.button);
   button.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           String str = "";
           for (CheckBox checkbox : list) {
             if (checkbox.isChecked()) {
               str += checkbox.getText();
             }
           }
           new AlertDialog.Builder(CheckBoxTest.this).setTitle("提示").setMessage(str).show();
         }
       });
   list = new ArrayList<CheckBox>();
   String[] str = new String[] {"复选框1", "复选框2", "复选框3", "复选框4"};
   for (String stritem : str) {
     CheckBox checkBox = new CheckBox(this);
     checkBox.setText(stritem);
     list.add(checkBox);
     linearLayout.addView(checkBox);
   }
 }
Esempio n. 14
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_guide2);

    cb_guide2 = (CheckBox) findViewById(R.id.cb_guide2);
    // 从sp中取出保存的sim卡序列号
    String simNumber = SpUtils.getInstance(this).get(SpUtils.SIM_NUMBER, null);
    // 如存在就需要更新cb_guide2的显示
    if (simNumber != null) {
      cb_guide2.setChecked(true);
      cb_guide2.setTextColor(Color.BLACK);
      cb_guide2.setText("已经绑定SIM卡");
    }

    // 设置监听
    cb_guide2.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) { // 选中, 保存
              String simNumber = MSUtils.getSimNumber(getApplicationContext());
              SpUtils.getInstance(getApplicationContext()).save(SpUtils.SIM_NUMBER, simNumber);
              cb_guide2.setChecked(true);
              cb_guide2.setTextColor(Color.BLACK);
              cb_guide2.setText("已经绑定SIM卡");
            } else { // 不选中, 移除
              SpUtils.getInstance(getApplicationContext()).remove(SpUtils.SIM_NUMBER);
              cb_guide2.setChecked(false);
              cb_guide2.setTextColor(Color.RED);
              cb_guide2.setText("还没有绑定SIM卡");
            }
          }
        });
  }
Esempio n. 15
0
  public void init() {

    TableLayout attendanceTable = (TableLayout) findViewById(R.id.attendanceTableLayout);
    CheckBox checkBox;
    TextView tv;
    ImageButton addBtn;
    for (int i = 0; i < 2; i++) {

      TableRow row = new TableRow(this);
      TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT);
      row.setLayoutParams(lp);
      checkBox = new CheckBox(this);
      tv = new TextView(this);
      addBtn = new ImageButton(this);
      addBtn.setImageResource(R.drawable.student_pic);
      addBtn.setMaxWidth(10);
      addBtn.setMaxHeight(10);
      checkBox.setText("Mark: ");
      tv.setText("Student " + i);
      row.addView(checkBox);
      row.addView(tv);
      row.addView(addBtn);
      attendanceTable.addView(row, i);
    }
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater =
        (LayoutInflater) CurContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View rowView = inflater.inflate(R.layout.option, parent, false);
    final int index = position;
    final CheckBox cboxView = (CheckBox) rowView.findViewById(R.id.optionCheckbox);
    cboxView.setText(Integer.toString(position + 1) + ". " + Values[position]);
    cboxView.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {

            if (cboxView.isChecked() && !selectedOptions.contains(index)) {
              selectedOptions.add(index);
              Toast.makeText(CurContext, cboxView.getText(), Toast.LENGTH_SHORT).show();
            } else if (!cboxView.isChecked() && selectedOptions.contains(index)) {
              selectedOptions.remove(index);
            }
          }
        });

    return rowView;
  }
Esempio n. 17
0
 private void setView() {
   try {
     mBtnChoose = (Button) findViewById(R.id.btn_show_choose);
     mBtnBack = (Button) findViewById(R.id.btn_back_to_pre);
     mChkSephiroth = (CheckBox) findViewById(R.id.chk_sephiroth);
     mChkSephiroth.setOnCheckedChangeListener(chkLeader);
     mChkKefka = (CheckBox) findViewById(R.id.chk_kefka);
     mChkKefka.setOnCheckedChangeListener(chkLeader);
     mChkExdeath = (CheckBox) findViewById(R.id.chk_exdeath);
     mChkExdeath.setOnCheckedChangeListener(chkLeader);
     mLlMoogles = (LinearLayout) findViewById(R.id.ll_moogles);
     mMoogles = getResources().getStringArray(R.array.moogles);
     mTxtCounter = (TextView) findViewById(R.id.txt_counter);
     mTxtLeader = (TextView) findViewById(R.id.txt_leader);
     for (int i = 0; i < mMoogles.length; i++) {
       CheckBox chkMoogle = new CheckBox(this);
       chkMoogle.setId(i);
       chkMoogle.setText(mMoogles[i]);
       chkMoogle.setOnCheckedChangeListener(chkMoogles);
       mLlMoogles.addView(chkMoogle);
     }
   } catch (Exception _ex) {
     Log.e("aaaaaaa", _ex.getMessage());
   }
 }
Esempio n. 18
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;
  }
Esempio n. 19
0
  public void showDialogInitializingCommandPlayer(
      final Activity uiContext, boolean warningNoneProvider, Runnable run, boolean showDialog) {
    String voiceProvider = osmandSettings.VOICE_PROVIDER.get();
    if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) {
      if (warningNoneProvider && voiceProvider == null) {
        Builder builder = new AccessibleAlertBuilder(uiContext);
        LinearLayout ll = new LinearLayout(uiContext);
        ll.setOrientation(LinearLayout.VERTICAL);
        final TextView tv = new TextView(uiContext);
        tv.setPadding(7, 3, 7, 0);
        tv.setText(R.string.voice_is_not_available_msg);
        tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19);
        ll.addView(tv);

        final CheckBox cb = new CheckBox(uiContext);
        cb.setText(R.string.shared_string_remember_my_choice);
        LinearLayout.LayoutParams lp =
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        lp.setMargins(7, 10, 7, 0);
        cb.setLayoutParams(lp);
        ll.addView(cb);

        builder.setCancelable(true);
        builder.setNegativeButton(
            R.string.shared_string_cancel,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                if (cb.isChecked()) {
                  osmandSettings.VOICE_PROVIDER.set(OsmandSettings.VOICE_PROVIDER_NOT_USE);
                }
              }
            });
        builder.setPositiveButton(
            R.string.shared_string_ok,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent(uiContext, SettingsActivity.class);
                intent.putExtra(
                    SettingsActivity.INTENT_KEY_SETTINGS_SCREEN,
                    SettingsActivity.SCREEN_GENERAL_SETTINGS);
                uiContext.startActivity(intent);
              }
            });

        builder.setTitle(R.string.voice_is_not_available_title);
        builder.setView(ll);
        // builder.setMessage(R.string.voice_is_not_available_msg);
        builder.show();
      }

    } else {
      if (player == null || !Algorithms.objectEquals(voiceProvider, player.getCurrentVoice())) {
        appInitializer.initVoiceDataInDifferentThread(uiContext, voiceProvider, run, showDialog);
      }
    }
  }
Esempio n. 20
0
 public View getView(Context context) throws UnsupportedOperationException {
   CheckBox checkbox = new CheckBox(context);
   checkbox.setLayoutParams(
       new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
   checkbox.setText(mLabel);
   checkbox.setChecked(mChecked);
   mView = (View) checkbox;
   return mView;
 }
	/**
	 * Returns the view for a specific item on the list
	 */
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView;

		final WorkItem currentItem = getItem(position);

		if (row == null) {
			LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
			row = inflater.inflate(mLayoutResourceId, parent, false);
		}

		row.setTag(currentItem);
		final CheckBox checkBox = (CheckBox) row
				.findViewById(R.id.checkToDoItem);
		final TextView txtDate = (TextView) row
				.findViewById(R.id.textDueDate);

		final Calendar c = Calendar.getInstance();
		c.setTime(currentItem.getDueDate());

		int year = c.get(Calendar.YEAR);
		int month = c.get(Calendar.MONTH);
		int day = c.get(Calendar.DAY_OF_MONTH);
		int hour = c.get(Calendar.HOUR_OF_DAY);
		int minute = c.get(Calendar.MINUTE);
		@SuppressWarnings("deprecation")
		String gmtTime = currentItem.getDueDate().toGMTString();
		// set current date into textview
		txtDate.setText(gmtTime);
		
		checkBox.setText(currentItem.getTitle());
		checkBox.setChecked(currentItem.isComplete());
		checkBox.setEnabled(true);
		checkBox.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				if (checkBox.isChecked()) {
					checkBox.setEnabled(false);
					if (mContext instanceof ToDoActivity) {
						ToDoActivity activity = (ToDoActivity) mContext;
						activity.checkItem(currentItem);
					}
				}
			}
		});
		
		Date currentDate = new Date();
		row.setBackgroundResource(R.color.normal);
		if(currentItem.getDueDate().before(currentDate))
		{
			row.setBackgroundResource(R.color.highlight);	
		}
		
		return row;
	}
Esempio n. 22
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    this.topLevelView = inflater.inflate(R.layout.fragment_parchoice, container, false);
    this.choiceListLeft = (LinearLayout) topLevelView.findViewById(R.id.layout_choice_left);
    this.choiceListRight = (LinearLayout) topLevelView.findViewById(R.id.layout_choice_right);

    getDialog().setTitle(R.string.game_add_combination);

    // this.combinations =
    // getArguments().getStringArrayList("combinations");
    this.selectedPlayersLeft = new boolean[this.names.size()];
    this.selectedPlayersRight = new boolean[this.names.size()];

    this.choiceListLeft.removeAllViews();
    this.choiceListRight.removeAllViews();
    // this.choiceList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    // create an array:
    String[] names_array = new String[this.names.size()];
    CheckBox currentPlayer;
    // CheckedTextView currentPlayer;
    Log.d("Dialog", "Have players list: " + this.players);
    for (int i = 0; i < names_array.length; i++) {
      // names_array[i] = this.names.get(i);
      Log.d("Dialog", "Adding " + this.names.get(i));
      // currentPlayer = new CheckedTextView(getActivity());
      currentPlayer = new CheckBox(getActivity());
      currentPlayer.setText(this.names.get(i));
      currentPlayer.setOnCheckedChangeListener(this);
      this.choiceListLeft.addView(currentPlayer);

      currentPlayer = new CheckBox(getActivity());
      currentPlayer.setText(this.names.get(i));
      currentPlayer.setOnCheckedChangeListener(this);
      this.choiceListRight.addView(currentPlayer);
    }
    Button confirmButton = (Button) topLevelView.findViewById(R.id.button_choice);
    confirmButton.setOnClickListener(this);

    this.topLevelView.requestLayout();
    return this.topLevelView;
  }
  private void setupFileList(OrgQueryBuilder agenda) {
    ArrayList<String> filenames = OrgProviderUtils.getFilenames(getContentResolver());
    for (String filename : filenames) {
      CheckBox checkBox = new CheckBox(this);
      checkBox.setText(filename);
      checkBox.setChecked(agenda.files.contains(filename));

      fileListView.addView(checkBox);
    }
  }
Esempio n. 24
0
 private void initializeFavoriteCheck() {
   if (ConnectorFactory.getConnector(cache).supportsAddToFavorite(cache, typeSelected)) {
     if (premFavPoints > 0) {
       favCheck.setVisibility(View.VISIBLE);
       favCheck.setText(getString(R.string.fav_points_remaining, premFavPoints));
     }
   } else {
     favCheck.setVisibility(View.GONE);
   }
 }
Esempio n. 25
0
        @Override
        public void onComplete(String value) {
          String username = mTwitter.getUsername();
          username = (username.equals("")) ? "No Name" : username;

          mTwitterBtn.setText("  Twitter  (" + username + ")");
          mTwitterBtn.setChecked(true);
          mTwitterBtn.setTextColor(Color.WHITE);

          Toast.makeText(TestConnect.this, "Connected to Twitter as " + username, Toast.LENGTH_LONG)
              .show();
        }
 /** Creates the new CheckBox Group based on the Input Type of current LogItem */
 public void createCheckboxGroup(ArrayList<String> options) {
   llayout.setVisibility(getView().VISIBLE);
   for (int i = 0; i < options.size(); i++) {
     LinearLayout.LayoutParams params =
         new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
     Log_Box = new CheckBox(this.getContext());
     Log_Box.setId(i);
     Log_Box.setText(options.get(i));
     llayout.addView(Log_Box, params);
   }
   // Todo: create Listener to add to database when input.
 }
Esempio n. 27
0
  public TriggerWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);
    mPrompt = prompt;

    this.setOrientation(LinearLayout.VERTICAL);

    mTriggerButton = new CheckBox(getContext());
    mTriggerButton.setId(QuestionWidget.newUniqueId());
    mTriggerButton.setText(getContext().getString(R.string.trigger));
    mTriggerButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
    // mActionButton.setPadding(20, 20, 20, 20);
    mTriggerButton.setEnabled(!prompt.isReadOnly());

    mTriggerButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mTriggerButton.isChecked()) {
              mStringAnswer.setText(mOK);
              Collect.getInstance()
                  .getActivityLogger()
                  .logInstanceAction(TriggerWidget.this, "triggerButton", "OK", mPrompt.getIndex());
            } else {
              mStringAnswer.setText(null);
              Collect.getInstance()
                  .getActivityLogger()
                  .logInstanceAction(
                      TriggerWidget.this, "triggerButton", "null", mPrompt.getIndex());
            }
          }
        });

    mStringAnswer = new TextView(getContext());
    mStringAnswer.setId(QuestionWidget.newUniqueId());
    mStringAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
    mStringAnswer.setGravity(Gravity.CENTER);

    String s = prompt.getAnswerText();
    if (s != null) {
      if (s.equals(mOK)) {
        mTriggerButton.setChecked(true);
      } else {
        mTriggerButton.setChecked(false);
      }
      mStringAnswer.setText(s);
    }

    // finish complex layout
    this.addView(mTriggerButton);
    // this.addView(mStringAnswer);
  }
Esempio n. 28
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    wifiInfo = wifiManager.getConnectionInfo();
    chkOpenCloseWifiBox = (CheckBox) findViewById(R.id.chkOpenCloseWifi);
    TextView tvWifiConfigurations = (TextView) findViewById(R.id.tvWifiConfigurations);
    TextView tvWifiInfo = (TextView) findViewById(R.id.tvWifiInfo);
    chkOpenCloseWifiBox.setOnCheckedChangeListener(this);

    if (wifiManager.isWifiEnabled()) {
      chkOpenCloseWifiBox.setText("Wifi已开启");
      chkOpenCloseWifiBox.setChecked(true);
    } else {
      chkOpenCloseWifiBox.setText("Wifi已关闭");
      chkOpenCloseWifiBox.setChecked(false);
    }

    // 获得Wifi信息
    StringBuffer sb = new StringBuffer();
    sb.append("Wifi信息\n");
    sb.append("MAC地址:" + wifiInfo.getMacAddress() + "\n");
    sb.append("接入点的BSSID:" + wifiInfo.getBSSID() + "\n");

    sb.append("IP地址(int):" + wifiInfo.getIpAddress() + "\n");
    sb.append("IP地址(Hex):" + Integer.toHexString(wifiInfo.getIpAddress()) + "\n");
    sb.append("IP地址:" + ipIntToString(wifiInfo.getIpAddress()) + "\n");
    sb.append("网络ID:" + wifiInfo.getNetworkId() + "\n");
    tvWifiInfo.setText(sb.toString());

    // 得到配置好的网络
    wifiConfigurations = wifiManager.getConfiguredNetworks();
    tvWifiConfigurations.setText("已连接的无线网络\n");
    for (WifiConfiguration wifiConfiguration : wifiConfigurations) {
      tvWifiConfigurations.setText(tvWifiConfigurations.getText() + wifiConfiguration.SSID + "\n");
    }
  }
Esempio n. 29
0
  public void setOptions(final JSONObject options) {
    final int persistence = options.optInt("persistence");
    if (persistence > 0) {
      mPersistence = persistence;
    }

    mPersistWhileVisible = options.optBoolean("persistWhileVisible");

    final long timeout = options.optLong("timeout");
    if (timeout > 0) {
      mTimeout = timeout;
    }

    final JSONObject link = options.optJSONObject("link");
    if (link != null) {
      try {
        final String linkLabel = link.getString("label");
        final String linkUrl = link.getString("url");
        addLink(linkLabel, linkUrl, " ");
      } catch (JSONException e) {
      }
    }

    final JSONArray inputs = options.optJSONArray("inputs");
    if (inputs != null) {
      mInputs = new ArrayList<PromptInput>();

      final ViewGroup group = (ViewGroup) findViewById(R.id.doorhanger_inputs);
      group.setVisibility(VISIBLE);

      for (int i = 0; i < inputs.length(); i++) {
        try {
          PromptInput input = PromptInput.getInput(inputs.getJSONObject(i));
          mInputs.add(input);

          View v = input.getView(getContext());
          styleInput(input, v);
          group.addView(v);
        } catch (JSONException ex) {
        }
      }
    }

    final String checkBoxText = options.optString("checkbox");
    if (!TextUtils.isEmpty(checkBoxText)) {
      mCheckBox = (CheckBox) findViewById(R.id.doorhanger_checkbox);
      mCheckBox.setText(checkBoxText);
      mCheckBox.setVisibility(VISIBLE);
    }
  }
 private void modifyContent(final long currentTimeMillis) {
   textView.setText(RUNTIME_CHANGE_TEXT + " " + currentTimeMillis);
   imageView.setImageResource(RUNTIME_CHANGE_IMAGE_RES_ID);
   imageView.setTag(R.id.image_view_tag_resource_id, RUNTIME_CHANGE_IMAGE_RES_ID);
   editText.setText(RUNTIME_CHANGE_TEXT + " " + currentTimeMillis);
   button.setText(RUNTIME_CHANGE_TEXT + " " + currentTimeMillis);
   radioButton1.setText(RUNTIME_CHANGE_TEXT + " " + currentTimeMillis + " ... 1");
   radioButton2.setText(RUNTIME_CHANGE_TEXT + " " + currentTimeMillis + " ... 2");
   radioButton3.setText(RUNTIME_CHANGE_TEXT + " " + currentTimeMillis + " ... 3");
   spinner.setSelection(new Random().nextInt(spinner.getCount()), true);
   imageButton.setImageResource(RUNTIME_CHANGE_IMAGE_RES_ID);
   imageButton.setTag(R.id.image_view_tag_resource_id, RUNTIME_CHANGE_IMAGE_RES_ID);
   autoCompleteTextView.setText(RUNTIME_CHANGE_TEXT + " " + currentTimeMillis);
   checkBox1.setText(RUNTIME_CHANGE_TEXT + " " + currentTimeMillis + " ... 1");
   checkBox2.setText(RUNTIME_CHANGE_TEXT + " " + currentTimeMillis + " ... 2");
   checkBox3.setText(RUNTIME_CHANGE_TEXT + " " + currentTimeMillis + " ... 3");
   checkBox1.setChecked(new Random().nextBoolean());
   checkBox2.setChecked(new Random().nextBoolean());
   checkBox3.setChecked(new Random().nextBoolean());
   toggleButton.setChecked(new Random().nextBoolean());
   toggleButton.setText(RUNTIME_CHANGE_TEXT + " " + currentTimeMillis);
   switchButton.setChecked(new Random().nextBoolean());
   progressBar.setProgress((int) (Math.random() * 100));
 }