daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Feb 21st, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var COLS:Int = 3;
  2. var tblLayout = findViewById<View>(R.id.tableLayout)as TableLayout
  3. tblLayout.removeAllViews()
  4. var SCV=scrollView
  5.     while(i</*количество строк*/) {
  6.         var tableRow:TableRow = TableRow(this);
  7.         tableRow.setLayoutParams(     LayoutParaLayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
  8.         var j:Int=0
  9.         while(j<COLS) {
  10.             var TV:TextView= TextView(this)
  11.             TV.setTextColor(getResources().getColor(android.R.color.black))
  12.             TV.setTextSize(15.toFloat())
  13.             TV.setHeight(TV.getTextSize().toInt()*2)
  14.             TV.setBackgroundResource(R.drawable.grid)
  15.             TV.setText(/*данные*/)
  16.             if((t % 3) == 0){
  17.                 TV.setWidth((SCV.getWidth()/(1.3).toFloat()).toInt())
  18.             }else{
  19.                 TV.setWidth((SCV.getWidth()-(SCV.getWidth()/(1.3).toFloat()).t())/2)
  20.             }
  21.             TV.setGravity(Gravity.CENTER)
  22.             TV.setTag(t)
  23.             TV.setOnClickListener {
  24.                 var position:Int= TV.getTag() as Int//номер ячейки                
  25.             }
  26.             tableRow.addView(TV,j)
  27.             t++
  28.             j++
  29.         }
  30.         tblLayout.addView(tableRow,i)
  31.         i++
  32.     }
  33. }
  34.      
  35. <ScrollView
  36.             android:id="@+id/scrollView"
  37.             android:layout_width="match_parent"
  38.             android:layout_weight="60"
  39.             android:orientation="vertical"
  40.             android:background="#ffffff"
  41.             android:layout_height="0dp">
  42.         <TableLayout
  43.                 android:id="@+id/tableLayout"
  44.                 android:layout_width="match_parent"
  45.                 android:layout_height="match_parent"/>
  46. </ScrollView>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top