@Override
public
void
onClick(View v) {
if
(v.getId()==R.id.keywordEnrol){
if
(tableLayout.getChildCount()>
3
)
{
Toast.makeText(getActivity().getApplicationContext(),
"등록할 수 있는 키워드 수를 초과하였습니다."
,Toast.LENGTH_SHORT).show();
}
else
{
tableRow =
new
TableRow(getActivity().getApplicationContext());
tableRow.setLayoutParams(
new
TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
TableRow.LayoutParams.WRAP_CONTENT
));
CheckBox checkBox =
new
CheckBox(getActivity().getApplicationContext());
checkBox.setTextColor(Color.DKGRAY);
checkBox.setTextSize(
20
);
checkBox.setText(keyword.getText());
tableRow.addView(checkBox);
tableLayout.addView(tableRow);
}
}
else
{
for
(
int
i =tableLayout.getChildCount()-
1
;i>
0
;i--){
Log.i(
"test"
,tableLayout.getChildCount()-
1
+
"/"
+i);
if
(((CheckBox)((TableRow)tableLayout.getChildAt(i)).getChildAt(
0
)).isChecked()){
Toast.makeText(getActivity().getApplicationContext(),((CheckBox)((TableRow)tableLayout.getChildAt(i)).getChildAt(
0
)).getText()+
"(을)를 삭제하였습니다."
,Toast.LENGTH_SHORT).show();
tableLayout.removeView(tableLayout.getChildAt(i));
}
}
}
}