final LinearLayout attractedTo = (LinearLayout) findViewById(R.id.register_attracted_to); final CheckBox male = new CheckBox(this); male.setText("Male"); male.setTextColor(getResources().getColor(R.color.foreground_text)); attractedTo.addView(male); final CheckBox female = new CheckBox(this); female.setText("Female"); female.setTextColor(getResources().getColor(R.color.foreground_text)); attractedTo.addView(female);
CheckBox mCheckBox = new CheckBox(this); //mCheckBox.setText(String.format("%s",header)); //mCheckBox.setId(index1); //mCheckBox.setLayoutParams(lp); // mCheckBox.setOnClickListener(this); //mCheckBox.setPadding(mCheckBox.getTotalPaddingLeft() + 10, 0, 0, 10); mCheckBox.setTextColor(Color.GREEN);
CheckBox mCheckBox= new CheckBox(this); mCheckBox.setTextColor(R.color.textcolor);
LinearLayout my_layout = (LinearLayout) findViewById(R.id.test); for (int n = 0; n < listitems.size(); n++) { CheckBox cb = new CheckBox(getApplicationContext()); cb.setId(Integer.parseInt(listitems.get(n).get("cbid"))); cb.setText(listitems.get(n).get("product")); cb.setTextColor(Color.BLACK); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); parms.leftMargin = 2; params.rightMargin = 2; params.topMargin = 2; params.bottomMargin = 2; my_layout.addView(cb,params); }
LinearLayout layout = (LinearLayout) findViewById(R.id.yourlayout); CheckBox chkTeamName = new CheckBox(this); chkTeamName.setText(teamName.get(i)); chkTeamName.setTextColor(Color.BLACK); layout.addView(chkTeamName);
CheckBox chk = new CheckBox(this); chk.setText("Testing"); chk.setTextColor(Color.BLUE);
if(attrs.length() > 0) { ScrollView mScrollView = new HorizontalScrollView(getApplicationContext()); mScrollView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); mScrollView.setFillViewport(true); LinearLayout attrControlsSubContainer = new LinearLayout(getBaseContext()); attrControlsSubContainer.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams layoutParams= new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT); attrControlsSubContainer.setLayoutParams(layoutParams); for(int i=0;i<attrs.length();i++) { CheckBox chkAttribute = new CheckBox(getBaseContext()); chkAttribute.setText(attrs.getJSONObject(i).getString("name")); chkAttribute.setTextColor(Color.BLACK); chkAttribute.setId(attrs.getJSONObject(i).getInt("id")); attrControlsSubContainer.addView(chkAttribute); } mScrollView.addView(attrControlsSubContainer); attributeControlContainer.addView(mScrollView); }
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);
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); } }
ch.setTextColor(Color.parseColor("#01A0AC")); ch.setId(j); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
gateway.setGravity(Gravity.CENTER); gateway.setTextColor(Color.BLACK); gateway.setText("Gateway"+i);
CheckBox chkBox = new CheckBox(this); chkBox.setId(++myid); // AS FOLLOWING, YOU SET SIZE RelativeLayout.LayoutParams chkBoxParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); // OR int width, int hieght); chkBox.setLayoutParams(chkBoxParams); chkBox.setGravity(Gravity.CENTER); chkBox.setTextColor(Color.BLACK); //chkBox.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); chkBox.setText("Scroll Test"); Your_Main_View_Holder_Layout.addView(chkBox);
cb.setId(Integer.parseInt(listitems.get(n).get("cbid"))); cb.setText(listitems.get(n).get("product")); cb.setTextColor(Color.BLACK); if (listitems.get(n).get("state").toString().equals("true")) { cb.setChecked(true); my_checked_layout.addView(cb); cb.setBackgroundColor(Color.argb(200, 8, 242, 2)); cb.setTextColor(Color.parseColor("#CFCFCF")); checkstate = true; } else { cb.setChecked(false); cb.setBackgroundColor(Color.argb(100, 5, 214, 0)); cb.setTextColor(Color.parseColor("#F7F7F7")); checkstate = false; my_layout.addView(cb);
cBox.setTextColor(0xFFFFFFFF); cBox.setText(values[position]); cBox.setTag(new Integer(position));
for (Answer a : q.getAnswers()) { final CheckBox cb = new CheckBox(this); cb.setId(Integer.valueOf(a.getId())); cb.setText(a.getValue()); cb.setTextColor(fontColor); cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub if(isChecked){ inviCheckox.append("-"+String.valueOf(buttonView.getId())); } }); lCheckList.addView(cb); }
dynaCheckBox.setTextColor(context.getResources().getColor(R.color.my_red_red)); dynaCheckBox.setTextColor(context.getResources().getColor(R.color.my_gold_color)); dynaCheckBox.setTextColor(context.getResources().getColor(R.color.my_exit_green));
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.setId(20); select_checkbox.setLayoutParams(innerParams); select_checkbox.setTextColor(Color.BLACK); select_checkbox.setGravity(Gravity.CENTER); select_checkbox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_place_bid); String[] sh=item_list(); int array_length=jArray.length(); LinearLayout linearLayout = (LinearLayout) findViewById(R.id.lyout); for(int c=0; c<jArray.length();c++){ CheckBox chk=new CheckBox(this); chk.setId(c+1); chk.setText("Click to add values"); chk.setTextColor(Color.GRAY); chk.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { String s="x"+buttonView.getId(); Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show(); switch(buttonView.getId()){ case 1: // do something on 1st checkbox break; case 2: //do something on 2nd checkbox break; //And SO ON for all checkboes } } }); linearLayout.addView(chk); } }
mCheckBx.setText(options_answers[i]); mCheckBx.setId(i); mCheckBx.setTextColor(Color.BLACK); mLayout.addView(mCheckBx); mBoxs.add(mCheckBx);