Java 类android.widget.TableRow.LayoutParams 实例源码

项目:rpgpack-android    文件:TableFragment.java   
@SuppressWarnings("deprecation")
    protected void setAddButtonStyle(TextView text){
        TableRow.LayoutParams textViewParams = new TableRow.LayoutParams();
        Display display = getActivity().getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int width = size.x;
        int height = size.y;
        textViewParams.height = height;
        textViewParams.width = width;
//      Log.d("width", "SCREEN.x == " + width);
        text.setMaxWidth(width);
        String uri = "@drawable/cell_shape_add";
        int imageResource = getResources().getIdentifier(uri, null, getActivity().getPackageName());
        Drawable res = getResources().getDrawable(imageResource);
        if (android.os.Build.VERSION.SDK_INT >= 16){
            text.setBackground(res);
        }
        else{
            text.setBackgroundDrawable(res);
        }
        text.setTextColor(getResources().getColor(R.color.own_grey));
        text.setSingleLine();
    }
项目:MyFlightbookAndroid    文件:ActCurrency.java   
private void BindTable() {
    TableLayout tl = (TableLayout) findViewById(R.id.tblCurrency);
    if (tl == null)
        throw new NullPointerException("tl is null in BindTable (ActCurrency)!");
    tl.removeAllViews();
    LayoutInflater l = getActivity().getLayoutInflater();

    if (m_rgcsi == null)
        return;

    for (CurrencyStatusItem csi : m_rgcsi) {
        try {
            // TableRow tr = new TableRow(this);

            TableRow tr = (TableRow) l.inflate(R.layout.currencyrow, tl, false);
            TextView tvAttribute = tr.findViewById(R.id.txtCsiAttribute);
            TextView tvValue = tr.findViewById(R.id.txtCsiValue);
            TextView tvDiscrepancy = tr.findViewById(R.id.txtCsiDiscrepancy);

            tvAttribute.setText(csi.Attribute);
            tvValue.setText(csi.Value);
            tvDiscrepancy.setText(csi.Discrepancy);
            if (csi.Discrepancy.length() == 0)
                tvDiscrepancy.setVisibility(View.GONE);

            tvAttribute.setTextColor(Color.BLACK);
            tvDiscrepancy.setTextColor(Color.BLACK);
            if (csi.Status.compareTo("NotCurrent") == 0)
                tvValue.setTextColor(Color.RED);
            else if (csi.Status.compareTo("GettingClose") == 0)
                tvValue.setTextColor(Color.BLUE);
            else
                tvValue.setTextColor(Color.argb(255, 0, 128, 0));

            tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        } catch (NullPointerException ex) { // should never happen.
            Log.e(MFBConstants.LOG_TAG, Log.getStackTraceString(ex));
        }
    }
}
项目:FMTech    文件:HistogramTable.java   
protected void onMeasure(int paramInt1, int paramInt2)
{
  super.onMeasure(paramInt1, paramInt2);
  if ((this.mLabelsOn) && (!this.mBars.isEmpty()))
  {
    int i = 0;
    for (int j = 0; j < getChildCount(); j++)
    {
      View localView1 = getChildAt(j);
      if ((localView1 instanceof TableRow))
      {
        TableRow localTableRow = (TableRow)localView1;
        int m = 0;
        for (int n = 0; n < localTableRow.getChildCount(); n++)
        {
          View localView2 = localTableRow.getChildAt(n);
          TableRow.LayoutParams localLayoutParams = (TableRow.LayoutParams)localView2.getLayoutParams();
          m += localLayoutParams.leftMargin + localView2.getMeasuredWidth() + localLayoutParams.rightMargin;
        }
        if (m - localTableRow.getMeasuredWidth() > i) {
          i = m - localTableRow.getMeasuredWidth();
        }
      }
    }
    if (i > 0)
    {
      for (int k = 0; k < this.mBars.size(); k++) {
        ((HistogramBar)this.mBars.get(k)).setMaxBarWidth(this.mMaxBarWidth - i);
      }
      this.mBars.clear();
    }
  }
}
项目:SIT    文件:TableActivity.java   
private TextView createTextView(boolean endline, boolean endcolumn){
    TextView text = new TextView(this, null, R.style.frag2HeaderCol);
    int bottom = endline ? 1 : 0;
    int right = endcolumn ? 1 :0;
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 0.3f);
    params.setMargins(1, 1, right, bottom);
    text.setLayoutParams(params);
    text.setPadding(4, 4, 10, 4);
    text.setBackgroundColor(getResources().getColor(R.color.white));
    return text;
}
项目:SIT    文件:TableFragment.java   
private TextView createTextView(boolean endline, boolean endcolumn){
    TextView text = new TextView(getActivity(), null, R.style.frag2HeaderCol);
    int bottom = endline ? 1 : 0;
    int right = endcolumn ? 1 :0;
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 0.3f);
    params.setMargins(1, 1, right, bottom);
    text.setLayoutParams(params);
    text.setPadding(4, 4, 10, 4);
    text.setBackgroundColor(getResources().getColor(R.color.white));
    return text;
}
项目:AquaBase    文件:DetailsFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle bundle) {
    View rootView = inflater.inflate(R.layout.fragment_details, container,
            false);

    // Fill the table layout with rows for the fields depending on the item
    TableLayout table = (TableLayout)rootView.findViewById(R.id.TableLayout);

    for (int i = 0; i < mLabelIds.size(); i++) {
        // Don't switch to an inflated XML file for each row: way too slow
        TableRow row = new TableRow(getActivity());
        row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
                                             LayoutParams.WRAP_CONTENT));
        row.setPadding(0, 3, 0, 3);

        TextView titleView = new TextView(getActivity());
        titleView.setText(mLabelIds.get(i));
        titleView.setPadding(0, 0, 12, 0);
        titleView.setGravity(Gravity.TOP);
        titleView.setTypeface(Typeface.DEFAULT_BOLD);
        row.addView(titleView);

        TextView valueView = new TextView(getActivity());
        valueView.setText(mValues.get(i));
        titleView.setGravity(Gravity.TOP);
        row.addView(valueView);

        table.addView(row, new TableLayout.LayoutParams(
                                LayoutParams.MATCH_PARENT,
                                LayoutParams.WRAP_CONTENT));
    }

    return rootView;
}
项目:Testes    文件:TableLayoutActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.layout_scroll);

    TableLayout tableLayout=(TableLayout) findViewById(R.id.table_layout);
    TableRow row= new TableRow(this);
    TableRow.LayoutParams rowLayoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
    row.setLayoutParams(rowLayoutParams);
    TableRow row2= new TableRow(this);
    TextView tv1 = new TextView(this);
    tv1.setSingleLine(false);
    tv1.setEllipsize(null);
    tv1.setTextSize(getResources().getDimension(R.dimen.textsize));
    tv1.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f));
    tv1.setHorizontallyScrolling(false);
    tv1.setText("THIS LINE OF THEXT SHOULD BE SINGFLE. DOUBLE MAYBE?");

    TextView tv2 = new TextView(this);
    tv2.setSingleLine(false);
    tv2.setEllipsize(null);
    tv2.setTextSize(getResources().getDimension(R.dimen.textsize));
    tv2.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f));
    tv2.setHorizontallyScrolling(false);
    tv2.setText("THIS LEINBE HAS to be multiline also?");

    row.addView(tv1);
    row2.addView(tv2);
    tableLayout.addView(row,2);
    tableLayout.addView(row2,3);

}
项目:terraingis    文件:AttributesFragment.java   
/**
 * buttons for view next items
 * @param next
 */
private void addNextPreviousItemsButton(boolean next)
{
    Button button = new Button(mMainActivity);

    int[] range;
    if(next)
    {
        button.setOnClickListener(nextItemsHandler);
        range = getNextRange();
    }
    else
    {
        button.setOnClickListener(previousItemsHandler);
        range = getPreviousRange();
    }

    button.setText(String.format("%d-%d", range[0]+1, range[1]+1));

    TableRow.LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, ConvertUnits.dp2px(HEIGHT_BUTTON_DP));
    params.span = mLayer.getAttributeHeader().getCountColumns();
    button.setLayoutParams(params);

    TableRow row = new TableRow(mMainActivity);
    row.addView(button);
    mTable.addView(row);
}
项目:buildAPKsApps    文件:Hof.java   
public void loadHofTable(){

    TableLayout tl = (TableLayout)findViewById(R.id.hoftable);       

String filecontent = getStringFromFile("halloffame");        

      if (filecontent != "") {

       String scores[] = filecontent.split(";");

       for (int i=0; i<scores.length; i++){

        String score[];
        score = scores[i].split(",");

        TableRow tr = new TableRow(this);
           tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));

           TextView points = new TextView(this);
           points.setGravity(Gravity.CENTER_VERTICAL);
           points.setGravity(Gravity.CENTER_HORIZONTAL);
           points.setTextColor(Color.BLACK);
           points.setText(score[0]);
           points.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
           tr.addView(points);

           TextView playername = new TextView(this);
           playername.setGravity(Gravity.CENTER_VERTICAL);
           playername.setGravity(Gravity.CENTER_HORIZONTAL);
           playername.setTextColor(Color.BLACK);
           playername.setText(score[1]);
           playername.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
           tr.addView(playername);

           TextView dat = new TextView(this);
           dat.setGravity(Gravity.CENTER_VERTICAL);
           dat.setGravity(Gravity.CENTER_HORIZONTAL);
           dat.setTextColor(Color.BLACK);
           dat.setText(score[2]);
           dat.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
           tr.addView(dat);

           tl.addView(tr,new TableLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));     
       }
      }  
  }
项目:Steppy-Android    文件:ShowLocalStep.java   
private void BuildTable() {

  sqlcon.open();
  Cursor c = sqlcon.readEntry();

  int rows = c.getCount();
  int cols = c.getColumnCount();

  c.moveToFirst();

  // outer for loop
  for (int i = 0; i < rows; i++) {

   TableRow row = new TableRow(this);
   row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
     LayoutParams.WRAP_CONTENT));

   // inner for loop
   for (int j = 0; j < cols; j++) {

    TextView tv = new TextView(this);
    tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.WRAP_CONTENT));
 //   tv.setBackgroundResource(R.drawable.cell_shape);
    tv.setGravity(Gravity.CENTER);
    tv.setTextSize(18);
    tv.setPadding(0, 5, 0, 5);

    tv.setText(c.getString(j));

    row.addView(tv);

   }

   c.moveToNext();

   table_layout.addView(row);

  }
/*  int tLastStep = 0;
  String tgl = "";
  Cursor tCursor = sqlcon.getLast();
  if (tCursor != null) {
        tLastStep = tCursor.getInt(0);
        tgl = tCursor.getString(4);
        tCursor.close();
    }

  Toast.makeText(ShowLocalStep.this,
            "Last step : "+Integer.toString(tLastStep)+" - "+tgl, Toast.LENGTH_LONG)
            .show();
            */
  sqlcon.close();

 }
项目:Newton_for_Android_AS    文件:LoginFragment.java   
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    setTitleText(R.string.login_bt);

    Context context = getActivity();

    //注册按钮
    Button registerBtn = new Button(context);
    registerBtn.setId(ID_REGISTER_BTN);
    registerBtn.setText(R.string.register_btn);
    registerBtn.setTextSize(17);
    registerBtn.setTextColor(Color.WHITE);
    registerBtn.setBackgroundResource(R.drawable.button_focused);
    registerBtn.setOnClickListener(this);

    RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
            UIUtil.dip2px(context, 60), LayoutParams.MATCH_PARENT);
    lp2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    lp2.addRule(RelativeLayout.CENTER_VERTICAL);
    addViewInTitleBar(registerBtn, lp2);

    //登录按钮
    Button loginBtn = (Button) view.findViewById(R.id.login_bt);
    loginBtn.setOnClickListener(this);
    loginBtn.setBackgroundDrawable(StateList.get());

    view.findViewById(R.id.qq_login_btn).setOnClickListener(this);
    view.findViewById(R.id.wechat_login_btn).setOnClickListener(this);
    view.findViewById(R.id.sina_weibo_login_btn).setOnClickListener(this);

    userNameEdit = (EditText) view.findViewById(R.id.username);
    passwordEdit = (EditText) view.findViewById(R.id.userpass);

    // 获取用户信息
    UserInfo userInfo = UserManager.getInstance().getUserInfo();
    if (userInfo != null) {
        userNameEdit.setText(userInfo.getUserName());
        passwordEdit.setText(userInfo.getPassword());
    }

    view.findViewById(R.id.forget_password_text).setOnClickListener(this);
}
项目:Newton_for_Android_AS    文件:IndividualCenterFragment.java   
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    setTitleText(R.string.individualCenterFragment_title);

    nickNameText = (TextView) view.findViewById(R.id.individual_nickname_tv);
    levelText = (TextView) view.findViewById(R.id.individual_level_tv);
    locationText = (TextView) view.findViewById(R.id.individual_location_tv);
    view.findViewById(R.id.individual_message).setOnClickListener(this);

    imageView = (ImageView) view.findViewById(R.id.avatar_image);
    imageView.setOnClickListener(this);

    Context context = getActivity();

    // 注销按钮
    logoutBtn = new ImageButton(context);
    logoutBtn.setId(ID_LOGOUT_BTN);
    logoutBtn.setImageResource(R.drawable.ic_logout);
    logoutBtn.setBackgroundResource(R.drawable.button_focused);
    logoutBtn.setOnClickListener(this);

    RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
            UIUtil.dip2px(context, 40), LayoutParams.MATCH_PARENT);
    lp2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    lp2.addRule(RelativeLayout.CENTER_VERTICAL);
    addViewInTitleBar(logoutBtn, lp2);

    listview = (RoundListView) view
            .findViewById(R.id.individual_center_listview);
    listview.setOnItemClickListener(this);

    items = new ArrayList<SettingItem>();
    items.add(new SettingItem(POSITION_RANK, context.getResources()
            .getDrawable(R.drawable.ic_rank_black), getResources().getString(R.string.myIntegralFragment_title)));
    items.add(new SettingItem(POSITION_BALANCE, context.getResources()
            .getDrawable(R.drawable.ic_balance_black), getResources().getString(R.string.aboutus)));
    items.add(new SettingItem(POSITION_TASK, context.getResources()
            .getDrawable(R.drawable.ic_task_black), getResources().getString(R.string.myTaskFragment_title)));

    items.add(new SettingItem(POSITION_TASK, context.getResources()
            .getDrawable(R.drawable.ic_message), getResources().getString(R.string.myMessageFragment_title)));

    mAdapter = new SettingAdapter(items);
    listview.setAdapter(mAdapter);

    // 先读取缓存的数据,然后再更新
    UserInfo userInfo = UserManager.getInstance().getUserInfo();
    DebugLog.i(TAG, "Cached UserInfo = " + userInfo);

    attachUserInfo2View(userInfo);
}
项目:Newton_for_Android_AS    文件:ConfirmWithCloseButtonDialog.java   
public ConfirmWithCloseButtonDialog(final Activity activity) {
    super(activity);

    RelativeLayout parentLayout = new RelativeLayout(activity);
    parentLayout.setBackgroundColor(Color.TRANSPARENT);

    setContentView(parentLayout, lpmw);

    float r = 10;
    float[] outerR = new float[] { r, r, r, r, r, r, r, r };
    RoundRectShape rr = new RoundRectShape(outerR, null, null);
    ShapeDrawable drawable = new ShapeDrawable(rr);
    drawable.getPaint().setColor(Color.WHITE);

    layout = new LinearLayout(activity);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setGravity(Gravity.CENTER);
    layout.setBackgroundDrawable(drawable);

    RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp1.topMargin = UIUtil.dip2px(activity, 10);
    lp1.rightMargin = UIUtil.dip2px(activity, 10);
    parentLayout.addView(layout, lp1);

    //关闭按钮
    ImageButton closeBtn = new ImageButton(activity);
    closeBtn.setBackgroundResource(R.drawable.emotionstore_progresscancelbtn);
    closeBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });

    RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    parentLayout.addView(closeBtn, lp2);

    setDim(0.5f);

    // 设置为屏幕宽度
    setWindowWidth(Environment.getInstance().getScreenWidth());
}
项目:MATSOL-Android    文件:MatrixDisplayActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    target = R.id.matrix_button;

    int currentIndex;
    TableRow tableRow;
    // Define the layout. 
    setContentView(R.layout.matrix_display_view);

    // Parse the values from the parent 
    Intent intent = getIntent();
    this.height = intent.getIntExtra(MatrixInputActivity.MATRIX_SIZE,5);
    this.matrix = new float[this.height][];
    for(int i=0;i<this.height;i++){
        this.matrix[i] = intent.getFloatArrayExtra(
                MatrixInputActivity.MATRIX_VALUES+i);
    }
    this.results = intent.getFloatArrayExtra(
            MatrixInputActivity.MATRIX_RESULTS);
    // the we are always a linear equation 
    this.width = this.height + 1;

    // initialize the array
    this.textViewArray = new TextView[this.width*this.height];

    // get the table view to draw in it
    matrixTable = (TableLayout)findViewById(R.id.matrix_display_table);

    // traverse rows
    for(int i=0;i<this.height;i++){
        //traverse each element of the row
        tableRow = new TableRow(this);
        for(int j=0;j<this.width;j++){
            currentIndex = i*this.width + j; // this points to the location of t                                                                      // editText in the matrix
            this.textViewArray[currentIndex] = new TextView(this);
            this.textViewArray[currentIndex].setLayoutParams(
                    new LayoutParams(
                        LayoutParams.FILL_PARENT,
                        LayoutParams.WRAP_CONTENT)
                    );
            this.textViewArray[currentIndex].setPadding(5, 5, 5, 5);
            if(j==this.width-1){
                this.textViewArray[currentIndex].setText(" " + this.results[i]);
            }else{
                this.textViewArray[currentIndex].setText(" " + this.matrix[i][j]);
            }
            tableRow.addView(this.textViewArray[currentIndex]);
        }
        textViewArray[0].measure(MeasureSpec.UNSPECIFIED,
                    MeasureSpec.UNSPECIFIED);
        // this will add target and position-specific views to hint the
        // user of what we are doing
        tableRow = decorateTableRow(tableRow, 
                    textViewArray[0].getMeasuredHeight(),
                    textViewArray[0].getMeasuredWidth(),
                    i);


        matrixTable.addView(tableRow, new TableLayout.LayoutParams(
                    LayoutParams.FILL_PARENT,
                    LayoutParams.WRAP_CONTENT));

    }

}
项目:MATSOL-Android    文件:MatrixDisplayActivity.java   
private TableRow decorateTableRow(TableRow tableRow, int height,
        int width, int row){
    ImageView leftImageView = new ImageView(this);
    ImageView rightImageView = new ImageView(this); 
    leftImageView.setBackgroundResource(R.drawable.left_edge);
    rightImageView.setBackgroundResource(R.drawable.right_edge);
    if(target==R.id.matrix_button){
        // we need to allocate two more elements
        ImageView insideLeftImageView = new ImageView(this);
        ImageView insideRightImageView = new ImageView(this);
        if(row==0){ // should change decorators for top decorators
            leftImageView.setBackgroundResource(
                    R.drawable.top_left_edge);
            rightImageView.setBackgroundResource(
                    R.drawable.top_right_edge);
            insideLeftImageView.setBackgroundResource(
                    R.drawable.top_right_edge); // this is not a mistake
            insideRightImageView.setBackgroundResource(
                    R.drawable.top_left_edge);
        }else if(row == this.height-1){
            leftImageView.setBackgroundResource(
                    R.drawable.bottom_left_edge);
            rightImageView.setBackgroundResource(
                    R.drawable.bottom_right_edge);
            insideLeftImageView.setBackgroundResource(
                    R.drawable.bottom_right_edge); // this is not a mistake
            insideRightImageView.setBackgroundResource(
                    R.drawable.bottom_left_edge);

        }else{
            insideRightImageView.setBackgroundResource(
                    R.drawable.left_edge);
            insideLeftImageView.setBackgroundResource(
                    R.drawable.right_edge);
        }
        insideLeftImageView.setLayoutParams(new LayoutParams(
                    height,width/5));
        insideRightImageView.setLayoutParams(new LayoutParams(
                    height,width/5));
        insideRightImageView.getLayoutParams().height = height;
        insideLeftImageView.getLayoutParams().height = height;
        insideRightImageView.getLayoutParams().width = width/5;
        insideLeftImageView.getLayoutParams().width = width/5;
        tableRow.addView(insideLeftImageView,this.width-1);
        tableRow.addView(insideRightImageView,this.width);

    }else{
        // this is a determinant button
    }
    leftImageView.setLayoutParams(new LayoutParams(
                height,width/10));
    rightImageView.setLayoutParams(new LayoutParams(
                height,width/10));
    leftImageView.getLayoutParams().height = height;
    rightImageView.getLayoutParams().height = height;
    leftImageView.getLayoutParams().width = width/5;
    rightImageView.getLayoutParams().width = width/5;
    tableRow.addView(leftImageView,0);
    tableRow.addView(rightImageView);
    return tableRow;
}
项目:MATSOL-Android    文件:MatrixInputActivity.java   
private TableRow decorateTableRow(TableRow tableRow, int height,
        int width, int row){
    ImageView leftImageView = new ImageView(this);
    ImageView rightImageView = new ImageView(this); 
    leftImageView.setBackgroundResource(R.drawable.left_edge);
    rightImageView.setBackgroundResource(R.drawable.right_edge);
    if(target==R.id.matrix_button){
        // we need to allocate two more elements
        ImageView insideLeftImageView = new ImageView(this);
        ImageView insideRightImageView = new ImageView(this);
        if(row==0){ // should change decorators for top decorators
            leftImageView.setBackgroundResource(
                    R.drawable.top_left_edge);
            rightImageView.setBackgroundResource(
                    R.drawable.top_right_edge);
            insideLeftImageView.setBackgroundResource(
                    R.drawable.top_right_edge); // this is not a mistake
            insideRightImageView.setBackgroundResource(
                    R.drawable.top_left_edge);
        }else if(row == this.height-1){
            leftImageView.setBackgroundResource(
                    R.drawable.bottom_left_edge);
            rightImageView.setBackgroundResource(
                    R.drawable.bottom_right_edge);
            insideLeftImageView.setBackgroundResource(
                    R.drawable.bottom_right_edge); // this is not a mistake
            insideRightImageView.setBackgroundResource(
                    R.drawable.bottom_left_edge);

        }else{
            insideRightImageView.setBackgroundResource(
                    R.drawable.left_edge);
            insideLeftImageView.setBackgroundResource(
                    R.drawable.right_edge);
        }
        insideLeftImageView.setLayoutParams(new LayoutParams(
                    height,width/5));
        insideRightImageView.setLayoutParams(new LayoutParams(
                    height,width/5));
        insideRightImageView.getLayoutParams().height = height;
        insideLeftImageView.getLayoutParams().height = height;
        insideRightImageView.getLayoutParams().width = width/5;
        insideLeftImageView.getLayoutParams().width = width/5;
        tableRow.addView(insideLeftImageView,this.width-1);
        tableRow.addView(insideRightImageView,this.width);

    }else{
        // this is a determinant button
    }
    leftImageView.setLayoutParams(new LayoutParams(
                height,width/10));
    rightImageView.setLayoutParams(new LayoutParams(
                height,width/10));
    leftImageView.getLayoutParams().height = height;
    rightImageView.getLayoutParams().height = height;
    leftImageView.getLayoutParams().width = width/5;
    rightImageView.getLayoutParams().width = width/5;
    tableRow.addView(leftImageView,0);
    tableRow.addView(rightImageView);
    return tableRow;
}
项目:rpgpack-android    文件:TableFragment.java   
/**
     * adds one column to the given row 
     * @param row
     */
    protected void addColumnToRow(final TableRow row){
        int columnIndex = row.getChildCount();
        int rowIndex = table.indexOfChild(row);
        if(rowIndex == -1){
            rowIndex = headerTable.indexOfChild(row);
            if(rowIndex == -1)         Log.d("critical", "cant find row!");
        }
        View newElement = null;
        //get the needed content_type by choosing it to be the first rows type
        View firstRowView = null;
        TableRow firstRow = (TableRow) table.getChildAt(0);
        if(firstRow != null){
            firstRowView = firstRow.getChildAt(columnIndex);
        }
        if(firstRowView instanceof EditText){
            newElement = initTextField(row, jacksonTable.getEntry(columnIndex, rowIndex));
        }
        else if(firstRowView instanceof LinearLayout){
            if(((LinearLayout) firstRowView).getChildAt(0) instanceof CheckBox){
                newElement = initCheckBox(row, jacksonTable.getEntry(columnIndex, rowIndex));
            }
            else{// if(((LinearLayout) firstRowView).getChildAt(0) instanceof TextView){
                newElement = initPopup(row, jacksonTable.getEntry(columnIndex, rowIndex), columnIndex, rowIndex);
            }
        }
        else{
            //firstRowView should be null now -> its a new column
            // could also be the first row inserted after an empty table
            // quick temp fix
            if(row == headerTable.getChildAt(0)) {
//              Log.d("row==headerTable", "col:"+columnIndex+ " row:"+rowIndex);
                newElement = initTextField(row, jacksonTable.getColumnHeader(columnIndex), false);
                Log.d("TableFragment", "setting onclicklistener");
                newElement.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        showDialog();
                    }
                });
            }
            else {
//              Log.d("row==ChildTable", "col:"+columnIndex+ " row:"+rowIndex);
                newElement = initTextField(row, jacksonTable.getEntry(columnIndex, rowIndex), true);
            }
        }
        row.addView(newElement);
        int width = getNeededWidth(columnIndex);
        int height = getNeededHeight(rowIndex, row);
//      int oldWidth = oneColumn.getMeasuredWidth();
//      int oldHeight = oneColumn.getMeasuredWidth();
        final LayoutParams lparams = new LayoutParams(width, height);
        newElement.setLayoutParams(lparams);
        // moved to initEditText
//        if (headerTable.indexOfChild(row) != -1) {
            //setHeaderTableStyle((EditText) newElement);
//          if(((EditText)newElement).getText().toString().isEmpty()) {
//              ((EditText) newElement)
//                      .setText(getResources().getString(R.string.headline)
//                              + " "
//                              + (((TableRow) headerTable.getChildAt(0))
//                                      .getChildCount()));
//          }
//      } else {
//          setTableStyle(newElement);
//      }

    }