0
我需要顯示錶格邊框,以及錶行邊界dynamically.I創建的表像這樣的邊框的動態表:如何創建與Android的
TableLayout tl = (TableLayout) findViewById(R.id.tableLayout1);
for (int i = initil; i <end; i++) {
TableRow tr = new TableRow(this);
tr.setTag(i);
TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT);
tableRowParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
TextView txtCode = new TextView(this);
txtCode.setTextSize(1, 12);
createView(tr, txtCode, productList.get(i).getProductCode());
TextView txtDes = new TextView(this);
txtDes.setTextSize(1, 12);
createView(tr, txtDes, productList.get(i).getDescription());
EditText txtQty = new EditText(this);
txtQty.setTextSize(2, 12);
txtQty.setHeight(4);
txtQty.setWidth(6);
txtQty.setId(i);
txtQty.setFocusable(true);
txtQty.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
txtQty.setText("0.00");
tr.addView(txtQty);
txtQty.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
Log.v("TAG", "afterTextChanged" + s.toString());
}
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
Log.v("TAG", "beforeTextChanged");
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
Log.v("TAG", "onTextChanged");
}
});
if(invPriceEdit.equals("") && invPriceEdit.equals("1")){
EditText txtPrice = new EditText(this);
txtPrice.setText(Double.toString(productList.get(i).getPrice()));
txtPrice.setTextSize(12);
txtPrice.setHeight(3);
txtPrice.setWidth(8);
tr.addView(txtPrice);
}else{
TextView txtPrice = new TextView(this);
txtPrice.setTextSize(12);
txtPrice.setWidth(8);
txtPrice.setText(Double.toString(productList.get(i).getPrice()));
}
Log.i("----" , Double.toString(productList.get(i).getPrice()));
tl.addView(tr);
tr.addView(t);
}
public void createView(TableRow tr, TextView t, String viewdata) {
t.setText(viewdata);
t.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
t.setTextColor(Color.DKGRAY);
t.setPadding(1, 0, 0, 0);
tr.setPadding(0, 0, 0, 0);
tr.addView(t);
}
如何給請幫我..
在此先感謝
這是不可能把單槓。是嗎? – Piraba