Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何以编程方式在tablerow中添加seekbar?_Android_Tablerow_Android Seekbar - Fatal编程技术网

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

Android 如何以编程方式在tablerow中添加seekbar?,android,tablerow,android-seekbar,Android,Tablerow,Android Seekbar,我有一个表布局,我想通过编程在每一行中添加seekbar。我该怎么做。。。?我已经有了seekbar的xml布局,但是如何以编程方式将其添加到tablerow 编辑:我还想显示除法器值,比如如果分配给seekbar的最大值是5,那么我想在seekbar下面显示0、1、2、3、4和5 试试这个 TableRow tr = new TableRow(this); tr.setLayoutParams(new TableRow.LayoutParams(TableRow.La

我有一个表布局,我想通过编程在每一行中添加seekbar。我该怎么做。。。?我已经有了seekbar的xml布局,但是如何以编程方式将其添加到tablerow

编辑:我还想显示除法器值,比如如果分配给seekbar的最大值是5,那么我想在seekbar下面显示0、1、2、3、4和5

试试这个

     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));

我添加了seekbar,但它的大小很小。如何增加它的尺寸?我已经读到布局和重量是用来使seekbar正确可见的。在这种情况下它有用吗??