xmlファイルではなくクラスコードのチェックボックスボタンのチェックマークを非表示にしたい。cuzチェックした場合は2つの背景を使用していますtruesetbackground..falseの場合setbackground"checkbox.png"
パブリッククラスListActivityはActivity{を拡張します
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
AbsoluteLayout ff = (AbsoluteLayout) this.findViewById(R.id.AbsoluteLayout1);
ScrollView myScrollView = (ScrollView) findViewById(R.id.scrollView1);
TableLayout tl =(TableLayout) findViewById(R.id.h103);
TableRow tr = (TableRow) findViewById(R.id.TableRow18);
CheckBox cb = (CheckBox) findViewById(R.id.CheckBox18);
TextView tv = (TextView) findViewById(R.id.TextView34);
// ScrollView myScrollView1 = new ScrollView(this);
TableLayout tl1 =new TableLayout(this);
TableRow tr1 = new TableRow(this);
final CheckBox buttonView = new CheckBox(this) ;
TextView tv1 = new TextView(this);
/*myScrollView.getLayoutParams();
ViewGroup.LayoutParams iv_params_b = myScrollView1.getLayoutParams();
myScrollView1.setLayoutParams(iv_params_b);*/
//buttonView.setVisibility(1);
buttonView.setBackground(getResources().getDrawable(R.drawable.checkbox));
//buttonView.setVisibility(View.GONE);
buttonView.setFocusable(false);
buttonView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(((CheckBox) v).isChecked())
{
//buttonView.setChecked(false);
buttonView.setBackground(getResources().getDrawable(R.drawable.star));
}else
{
//buttonView.setChecked(true);
buttonView.setBackground(getResources().getDrawable(R.drawable.checkbox));
}
}
});
/* if(isChecked)
{
buttonView.setBackground(getResources().getDrawable(R.drawable.star));
}else
{
buttonView.setBackground(getResources().getDrawable(R.drawable.checkbox));
} */
ViewGroup.LayoutParams iv_params_b = tl.getLayoutParams();
tl1.setLayoutParams(iv_params_b);
ViewGroup.LayoutParams iv_params_b1 = tr.getLayoutParams();
tr1.setLayoutParams(iv_params_b1);
ViewGroup.LayoutParams iv_params_b2 = cb.getLayoutParams();
buttonView.setLayoutParams(iv_params_b2);
ViewGroup.LayoutParams iv_params_b3 = tv.getLayoutParams();
tv1.setLayoutParams(iv_params_b3);
tl.addView(tr1);
tr1.addView(buttonView);
}
}