我想在表格布局中添加边框,但是我只能在tablelayout中添加boreder到行,我想为表格布局添加coloumn边框,但是当我尝试在tablerow中添加布局边距到textview时,这是不可能的,找到可能的解决方案。
public class servicehistryload extends
AsyncTask<Void, Void, ArrayList<ServicehistryDetails>> {
@Override
protected ArrayList<ServicehistryDetails> doInBackground(Void... args0) {
HashMap<String, String> user = session.getUserDetails();
path.setNamespace();
path.setUrl();
path.setMethod_name("servicehistory");
path.setSoap_action();
// TODO Auto-generated method stub
Webservice service = new Webservice(path.getNamespace(),
path.getMethod_name(), path.getUrl(), path.getSoap_action());
try {
SoapObject request = service.getRequest();
SoapSerializationEnvelope envelope = service
.getEnvelope(request);
PropertyInfo senduserid = new PropertyInfo();
senduserid.setName("userid");
// senduserid.setValue(user.get(Session.User_Id));
senduserid.setValue("adkl1");
request.addProperty(senduserid);
SoapObject response = service.getResponse(envelope);
Log.i("Service History ", response.toString());
if (servicehistdetaillst.size() > 0) {
servicehistdetaillst.clear();
}
int count = response.getPropertyCount();
for (int i = 0; i < count; i++) {
SoapObject result = (SoapObject) response.getProperty(i);
ServicehistryDetails serhistdet = new ServicehistryDetails();
if(result.getProperty(2)!=null){
serhistdet.setSrno(result.getPropertyAsString(2));
}
else{
serhistdet.setSrno("");
}
if (result.getProperty(4) != null) {
serhistdet.setSessid(result.getPropertyAsString(4));
} else {
}
if (result.getProperty(7) != null) {
serhistdet.setVinno(result.getPropertyAsString(7));
} else {
}
if (result.getProperty(1) != null) {
serhistdet.setDealer(result.getPropertyAsString(1));
} else {
}
if (result.getProperty(3) != null) {
serhistdet.setServdate(result.getPropertyAsString(3));
} else {
}
if (result.getProperty(5) != null) {
serhistdet.setStatus(result
.getPrimitivePropertySafelyAsString("Status"));
} else {
}
if (result.getProperty(0) != null) {
serhistdet.setAction(result.getPropertyAsString(0));
} else {
serhistdet.setAction("N/A");
}
if(result.getProperty(6)!=null){
serhistdet.setTeklin(result.getPropertyAsString(6));
}
else{
serhistdet.setTeklin("");
}
serhistdet.setDetails("Details");
servicehistdetaillst.add(serhistdet);
}
} catch (Exception e) {
e.printStackTrace();
}
return servicehistdetaillst;
}
protected void onPostExecute(
ArrayList<ServicehistryDetails> servicehistlist) {
boolean alternateclr=true;
servicehistorylist = new TextView[servicehistlist.size()];
TableRow servicehistinnerrow = new TableRow(ServiceHistory.this);
servicehistinnerrow.setId(10);
servicehistinnerrow.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
servicehistinnerrow.setBackgroundResource(R.color.red);
srno = new TextView(ServiceHistory.this);
srno.setId(1);
srno.setText(R.string.servicehistrytabrowsrno);
srno.setTextColor(Color.parseColor("#FAFAFA"));
servicehistinnerrow.addView(srno);
sessid = new TextView(ServiceHistory.this);
sessid.setId(2);
sessid.setText(R.string.servicehistrytabrows_sessId);
sessid.setPadding(20, 0, 0, 0);
sessid.setTextColor(Color.parseColor("#FAFAFA"));
servicehistinnerrow.addView(sessid);
vinno = new TextView(ServiceHistory.this);
vinno.setId(3);
vinno.setText(R.string.servicehistrytabrows_vinno);
vinno.setPadding(20, 0, 0, 0);
vinno.setTextColor(Color.parseColor("#FAFAFA"));
servicehistinnerrow.addView(vinno);
deal = new TextView(ServiceHistory.this);
deal.setId(4);
deal.setText(R.string.servicehistrytabrows_deal);
deal.setPadding(20, 0, 0, 0);
deal.setTextColor(Color.parseColor("#FAFAFA"));
servicehistinnerrow.addView(deal);
teklin = new TextView(ServiceHistory.this);
teklin.setId(5);
teklin.setText(R.string.servicehistrytabrows_teklin);
teklin.setPadding(20, 0, 0, 0);
teklin.setTextColor(Color.parseColor("#FAFAFA"));
servicehistinnerrow.addView(teklin);
servdate = new TextView(ServiceHistory.this);
servdate.setId(6);
servdate.setText(R.string.servicehistrytabrows_servDate);
servdate.setPadding(20, 0, 0, 0);
servdate.setTextColor(Color.parseColor("#FAFAFA"));
servicehistinnerrow.addView(servdate);
status = new TextView(ServiceHistory.this);
status.setId(7);
status.setText(R.string.servicehistrytabrows_status);
status.setPadding(20, 0, 0, 0);
status.setTextColor(Color.parseColor("#FAFAFA"));
servicehistinnerrow.addView(status);
action = new TextView(ServiceHistory.this);
action.setId(8);
action.setText(R.string.servicehistrytabrows_action);
action.setPadding(20, 0, 0, 0);
action.setTextColor(Color.parseColor("#FAFAFA"));
servicehistinnerrow.addView(action);
dertails = new TextView(ServiceHistory.this);
dertails.setId(9);
dertails.setText(R.string.servicehistrytabrows_details);
dertails.setTextColor(Color.parseColor("#FAFAFA"));
dertails.setPadding(20, 0, 0, 0);
String ss = dertails.getText().toString();
servicehistinnerrow.addView(dertails);
servicehistorttablay.addView(servicehistinnerrow,
new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
for (int i = 0; i < servicehistlist.size(); i++) {
int leftMargin=10;
int topMargin=2;
int rightMargin=10;
int bottomMargin=2;
TableRow servicehistinnerrowvalues = new TableRow(ServiceHistory.this);
servicehistinnerrowvalues.setId(i);
TableLayout.LayoutParams tableRowParams=
new TableLayout.LayoutParams
(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT);
tableRowParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
servicehistinnerrowvalues.setLayoutParams(tableRowParams);
servicehistinnerrowvalues.setBackgroundResource(R.drawable.row_border);
/*if(alternateclr==true){
servicehistinnerrowvalues.setBackgroundResource(R.color.antiquewhite);
alternateclr= false;
}
else{
servicehistinnerrowvalues.setBackgroundResource(R.color.lemon);
alternateclr=true;
}*/
TextView seriano=new TextView(ServiceHistory.this);
seriano.setId(i);
seriano.setText(String.valueOf(i));
seriano.setPadding(20, 0, 0, 0);
seriano.setBackgroundColor(Color.WHITE);
seriano.setGravity(Gravity.CENTER_HORIZONTAL);
seriano.setGravity(Gravity.CENTER_VERTICAL);
servicehistinnerrowvalues.addView(seriano);
servicehistorylist[i]= new TextView(ServiceHistory.this);
servicehistorylist[i].setTag(i);
servicehistorylist[i].setText(servicehistdetaillst.get(i).getSessid());
servicehistorylist[i].setPadding(20, 0, 0, 0);
servicehistorylist[i].setBackgroundColor(Color.WHITE);
servicehistinnerrowvalues.addView(servicehistorylist[i]);
TextView vinnumber=new TextView(ServiceHistory.this);
vinnumber.setId(i);
vinnumber.setText(servicehistlist.get(i).getVinno());
vinnumber.setPadding(20, 0, 0, 0);
vinnumber.setBackgroundColor(Color.WHITE);
servicehistinnerrowvalues.addView(vinnumber);
TextView dealers=new TextView(ServiceHistory.this);
dealers.setId(i);
dealers.setText(servicehistlist.get(i).getDealer());
dealers.setPadding(20, 0, 0, 0);
dealers.setBackgroundColor(Color.WHITE);
servicehistinnerrowvalues.addView(dealers);
TextView teklinears=new TextView(ServiceHistory.this);
teklinears.setId(i);
teklinears.setText(servicehistlist.get(i).getTeklin());
teklinears.setPadding(20, 0, 0, 0);
teklinears.setBackgroundColor(Color.WHITE);
servicehistinnerrowvalues.addView(teklinears);
TextView servicedetail=new TextView(ServiceHistory.this);
servicedetail.setId(i);
servicedetail.setText(servicehistlist.get(i).getServdate());
servicedetail.setPadding(20, 0, 0, 0);
servicedetail.setBackgroundColor(Color.WHITE);
servicehistinnerrowvalues.addView(servicedetail);
TextView stat=new TextView(ServiceHistory.this);
stat.setId(i);
stat.setText(servicehistlist.get(i).getStatus());
stat.setPadding(20, 0, 0, 0);
stat.setBackgroundColor(Color.WHITE);
servicehistinnerrowvalues.addView(stat);
TextView actions=new TextView(ServiceHistory.this);
actions.setId(i);
actions.setText(servicehistlist.get(i).getAction());
actions.setPadding(20,0,0,0);
actions.setBackgroundColor(Color.WHITE);
servicehistinnerrowvalues.addView(actions);
TextView details=new TextView(ServiceHistory.this);
details.setId(i);
details.setText(servicehistlist.get(i).getDetails());
details.setPadding(20, 0, 0, 0);
details.setBackgroundColor(Color.WHITE);
servicehistinnerrowvalues.addView(details);
servicehistorttablay.addView(servicehistinnerrowvalues,
new TableLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
}
}