如何以编程方式在tablerow中添加seekbar?

时间:2015-10-18 11:31:53

标签: android tablerow android-seekbar

我有一个表格布局,我希望以编程方式在每行中添加搜索栏。我怎样才能做到这一点...?我已经有了搜索栏的xml布局,但是如何在tablerow中添加以编程方式

编辑:我还想显示分频器值,就像分配给搜索栏的最大值是5,然后我想在搜索栏下方显示0,1,2,3,4和5。

1 个答案:

答案 0 :(得分:0)

试试这个

     TableRow tr = new TableRow(this);
        tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
        /* Create a SeekBar to be the row-content. */
      SeekBar seekBar = new SeekBar(this);
            seekBar.setMax(15);
    //      seekBar.setIndeterminate(true);

            ShapeDrawable thumb = new ShapeDrawable(new OvalShape());

            thumb.setIntrinsicHeight(80);
            thumb.setIntrinsicWidth(30);
            seekBar.setThumb(thumb);
            seekBar.setProgress(1);
            seekBar.setVisibility(View.VISIBLE);
            seekBar.setBackgroundColor(Color.BLUE);

            LayoutParams lp = new LayoutParams(200, 50);
            seekBar.setLayoutParams(lp); 
   seekBar.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));