CheckBox checkbox = new CheckBox(this); checkbox.setText("completed"); checkbox.setTextSize(TypedValue.COMPLEX_UNIT_PT, 10); checkbox.setTextColor(Color.BLACK); checkbox.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); LinearLayout layout = (LinearLayout)findViewById(R.id.layoutku); layout.addView(checkbox);
ViewGroup.LayoutParams checkbox_relativeParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); checkbox_relativeParams.width = ViewGroup.LayoutParams.MATCH_PARENT; checkbox_relativeParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; CheckBox cb = new CheckBox(getActivity()); cb.setText("I'm dynamic!"); cb.setGravity(Gravity.CENTER); cb.setTextSize(17); cb.setPadding(4,4,4,4); cb.setLayoutParams(checkbox_relativeParams);
public void startQuizClick(View v) { count++; HashMap<String, String> h1 = questionlist.get(k); question.setText(h1.get("question_text")); val = Integer.parseInt(h1.get("total_options")); LayoutInflater inflater = (LayoutInflater) ACTIVITYNAME.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); for (int i = 0; i < Integer.parseInt(h1.get("total_options")); i++) { View view = inflater.inflate(R.layout.row_layout, null); CheckBox cb = (CheckBox) view.findViewById(R.id.checkBox); HashMap<String, String> h2 = optionlist.get(i); cb.setId(i); cb.setEnabled(true); cb.setTextColor(getResources().getColor(R.color.textColor)); cb.setText(h2.get("option_text" + i)); cb.setTextSize(14); cb.setOnCheckedChangeListener(this); cb.setTag(i); linearLay1.addView(view); } }
List<CheckBox> yourCheckBoxes = new ArrayList<CheckBox>(); List<EditText> yourEditTexts = new ArrayList<EditText>(); try { JSONObject json_row = new JSONObject(json.getString("row" + x)); CheckBox chb = new CheckBox(this); chb.setText(json_row.getString("pregunta")); chb.setId(json_row.getInt("pregunta_verificacion_supervision")); chb.setTextSize(10); chb.setPadding(8, 3, 8, 3); chb.setTypeface(Typeface.SERIF, Typeface.BOLD_ITALIC); chb.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); lm.addView(chb); EditText et = new EditText(this); et.setHint("observaciones"); et.setId(json_row.getInt("pregunta_verificacion_supervision")); et.setTextSize(10); et.setPadding(8, 3, 8, 3); et.setTypeface(Typeface.SERIF, Typeface.BOLD_ITALIC); et.setInputTyp
public void startQuizClick() { HashMap<String, String> h1 = new HashMap<>(); for (int i = 0; i < 5; i++) { // cb is custom checkbox CheckBox cb = new CheckBox(this); cb.setLayoutParams(new LinearLayout.LayoutParams(100,100)); cb.setId(i); cb.setEnabled(true); cb.setTextColor(ContextCompat.getColor(Main2Activity.this,R.color.colorAccent)); cb.setText("test"); cb.setTextSize(14); cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Log.e("item checked","ischedked"+isChecked); } }); //linear layout lli.addView(cb); } }
select_checkbox.setTextColor(Color.BLACK); select_checkbox.setGravity(Gravity.CENTER); select_checkbox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12); plan_trip_tr_data.addView(select_checkbox);
dynaCheckBox.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);