package com.jqyd.newprocess; import java.util.ArrayList; import com.jqyd.adapter.TableAdapter; import com.jqyd.app.TableCell; import com.jqyd.app.TableRow; import com.jqyd.manager.R; import com.jqyd.model.PositionInfo; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.DisplayMetrics; import android.util.Log; import android.view.View; import android.view.Window; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.LinearLayout.LayoutParams; import android.widget.ListView; public class LocDesc extends Activity implements OnClickListener { private ListView listView; private Button back;//返回 private TextView title; private LinearLayout right_layout; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.positioninfo); listView = (ListView) this.findViewById(R.id.listView); back = (Button) this.findViewById(R.id.back); back.setOnClickListener(this); title = (TextView) this.findViewById(R.id.title); title.setText("文字详情"); right_layout = (LinearLayout) this.findViewById(R.id.right_layout); right_layout.setVisibility(LinearLayout.INVISIBLE); Intent intent = getIntent(); ArrayList<PositionInfo> locations = (ArrayList<PositionInfo>)intent.getSerializableExtra("locList"); ArrayList<TableRow> locTable = new ArrayList<TableRow>(); TableCell[] locationTitle = new TableCell[9];// 每行9个单元 DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metric); int width = metric.widthPixels; // 屏幕宽度(像素) int height = metric.heightPixels; // 屏幕高度(像素) Log.i("LOGIN", "宽度:"+width+","+height); if(width >=800){//大屏幕 locationTitle[0] = new TableCell("姓名", 120, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[1] = new TableCell("时间", 240, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[2] = new TableCell("定位结果", 150, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[3] = new TableCell("经度", 150, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[4] = new TableCell("纬度", 150, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[5] = new TableCell("省", 150, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[6] = new TableCell("市", 150, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[7] = new TableCell("县", 150, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[8] = new TableCell("定位详情", 280, LayoutParams.WRAP_CONTENT, TableCell.STRING); }else{ locationTitle[0] = new TableCell("姓名", 120, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[1] = new TableCell("时间", 120, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[2] = new TableCell("定位结果", 120, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[3] = new TableCell("经度", 80, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[4] = new TableCell("纬度", 80, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[5] = new TableCell("省", 80, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[6] = new TableCell("市", 80, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[7] = new TableCell("县", 80, LayoutParams.WRAP_CONTENT, TableCell.STRING); locationTitle[8] = new TableCell("定位详情", 240, LayoutParams.WRAP_CONTENT, TableCell.STRING); } locTable.add(new TableRow(locationTitle)); for(PositionInfo position : locations){ String dwResult = ""; if(position.getSucess() == 0){ dwResult = "成功"; }else{ dwResult = "失败"; } TableCell[] cells = new TableCell[9]; String provice = ""; String city = ""; String country = ""; if(position.getProvince() == null || position.getProvince().equals("")){ provice = " "; }else{ provice = position.getProvince(); } if(position.getCity() == null || position.getCity().equals("")){ city = " "; }else{ city = position.getCity(); } if(position.getCountry() == null || position.getCountry().equals("")){ country = " "; }else{ country = position.getCountry(); } if(width >=800){//大屏幕 cells[0] = new TableCell(position.getZdmc(), 120, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[1] = new TableCell(position.getAddTime(), 240, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[2] = new TableCell(dwResult, 150, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[3] = new TableCell(position.getLon()+"", 150, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[4] = new TableCell(position.getLat()+"", 150, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[5] = new TableCell(provice, 150, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[6] = new TableCell(city, 150, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[7] = new TableCell(country, 150, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[8] = new TableCell(position.getContent(), 280, LayoutParams.WRAP_CONTENT, TableCell.STRING); }else{ System.out.println("---------:"+position.getLon()+","+position.getLat()); cells[0] = new TableCell(position.getZdmc(), 120, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[1] = new TableCell(position.getAddTime(), 120, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[2] = new TableCell(dwResult, 120, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[3] = new TableCell(position.getLon()+"", 80, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[4] = new TableCell(position.getLat()+"", 80, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[5] = new TableCell(provice, 80, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[6] = new TableCell(city, 80, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[7] = new TableCell(country, 80, LayoutParams.WRAP_CONTENT, TableCell.STRING); cells[8] = new TableCell(position.getContent(), 240, LayoutParams.WRAP_CONTENT, TableCell.STRING); } locTable.add(new TableRow(cells)); } TableAdapter tableAdapterContent = new TableAdapter(this, locTable); listView.setAdapter(tableAdapterContent); } @Override public void onClick(View v) { // TODO Auto-generated method stub if(v == back){ finish(); } } }