我想在複選框按鈕中的類代碼而不是xml文件中隱藏複選標記。 因爲我是用兩個背景檢查是否屬實組後臺..如果假組後臺「checkbox.png」如何設置複選標記隱藏
公共類ListActivity延伸活動{
@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);
}
}
http://learningnerd.wordpress.com/2006/09/06/english-grammar-types-of-phrases/和http://www.lel.ed.ac.uk/grammar/overview.html。無法理解你想要什麼以及你有什麼。對不起:-( – g00dy 2013-03-04 13:37:46
當我點擊複選框按鈕有藍色複選標記。我想隱藏這個複選標記只因爲我使用不同的背景 – user1714553 2013-03-04 13:39:44
請參閱此鏈接(http://developer.android.com/reference/ android/view/View.html#INVISIBLE),如果你在執行時遇到問題,請回到這裏並解釋。 – g00dy 2013-03-04 13:41:17