コード例 #1
0
ファイル: MainActivity.java プロジェクト: Red680812/MyObdDemo
  private void addTableRow(String key, String val) {
    TableLayout tl = (TableLayout) findViewById(R.id.data_table);
    TableRow tr = new TableRow(this);
    MarginLayoutParams params =
        new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.setMargins(TABLE_ROW_MARGIN, TABLE_ROW_MARGIN, TABLE_ROW_MARGIN, TABLE_ROW_MARGIN);
    tr.setLayoutParams(params);
    tr.setBackgroundColor(Color.BLACK);
    TextView name = new TextView(this);
    name.setGravity(Gravity.RIGHT);
    name.setText(key + ": ");
    TextView value = new TextView(this);
    value.setGravity(Gravity.LEFT);
    value.setText(val);
    tr.addView(name);
    tr.addView(value);
    tl.addView(
        tr, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    /*
     * TODO remove this hack
     *
     * let's define a limit number of rows
     */
    if (tl.getChildCount() > 10) tl.removeViewAt(0);
  }
コード例 #2
0
 private View getFooterView() {
   if (mFooterView == null) {
     FrameLayout fl = new FrameLayout(getActivity());
     TextView tv = new TextView(getActivity());
     tv.setGravity(Gravity.CENTER);
     tv.setTextColor(0xFFaaaaaa);
     tv.setBackgroundColor(0xFFffffff);
     FrameLayout.LayoutParams params =
         new FrameLayout.LayoutParams(
             ViewGroup.LayoutParams.MATCH_PARENT, (int) CommonUtils.dpToPx(getActivity(), 50));
     fl.addView(tv, params);
     mFooterView = fl;
   }
   TextView tv = (TextView) mFooterView.getChildAt(0);
   tv.setText("共有" + SongManager.with(getActivity()).getSongSize() + "首歌");
   return mFooterView;
 }
コード例 #3
0
  private void SetBackGroundforList() {
    // TODO Auto-generated method stub
    mDownView_parent_txt1 = new TextView(activity.getApplicationContext());
    RelativeLayout.LayoutParams lp1 =
        new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    mDownView_parent_txt1.setId(Integer.parseInt("111111"));
    mDownView_parent_txt1.setLayoutParams(lp1);
    mDownView_parent_txt1.setGravity(Gravity.CENTER_HORIZONTAL);
    mDownView_parent_txt1.setText(HalfText);
    mDownView_parent_txt1.setWidth(textwidth2);
    mDownView_parent_txt1.setPadding(0, textheight / 4, 0, 0);
    mDownView_parent_txt1.setHeight(textheight);
    mDownView_parent_txt1.setBackgroundColor(Color.parseColor(FullColor));
    mDownView_parent_txt1.setTextColor(Color.parseColor(TextColor));
    mDownView_parent_txt1.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    mDownView_parent.addView(mDownView_parent_txt1, 0);

    //         if(SwipeType==Double){
    //             mDownView_parent_txt2 = new TextView(activity.getApplicationContext());
    //             mDownView_parent_txt2.setId(222222);
    //             RelativeLayout.LayoutParams lp2 =new
    // RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
    //             lp2.addRule(RelativeLayout.LEFT_OF,mDownView_parent_txt1.getId());
    //             mDownView_parent_txt2.setLayoutParams(lp2);
    //             mDownView_parent_txt2.setGravity(Gravity.CENTER_HORIZONTAL);
    //             mDownView_parent_txt2.setText(FullText);
    //             mDownView_parent_txt2.setWidth(textwidth);
    //             mDownView_parent_txt2.setPadding(0, textheight/4, 0, 0);
    //             mDownView_parent_txt2.setHeight(textheight);
    //             mDownView_parent_txt2.setBackgroundColor(Color.parseColor(FullColor));
    //             mDownView_parent_txt2.setTextColor(Color.parseColor(TextColor));
    //             mDownView_parent_txt2.setCompoundDrawablesWithIntrinsicBounds(null ,
    // FullDrawable, null, null );
    //             mDownView_parent.addView(mDownView_parent_txt2, 1);
    //         }
  }