Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var COLS:Int = 3;
- var tblLayout = findViewById<View>(R.id.tableLayout)as TableLayout
- tblLayout.removeAllViews()
- var SCV=scrollView
- while(i</*количество строк*/) {
- var tableRow:TableRow = TableRow(this);
- tableRow.setLayoutParams( LayoutParaLayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
- var j:Int=0
- while(j<COLS) {
- var TV:TextView= TextView(this)
- TV.setTextColor(getResources().getColor(android.R.color.black))
- TV.setTextSize(15.toFloat())
- TV.setHeight(TV.getTextSize().toInt()*2)
- TV.setBackgroundResource(R.drawable.grid)
- TV.setText(/*данные*/)
- if((t % 3) == 0){
- TV.setWidth((SCV.getWidth()/(1.3).toFloat()).toInt())
- }else{
- TV.setWidth((SCV.getWidth()-(SCV.getWidth()/(1.3).toFloat()).t())/2)
- }
- TV.setGravity(Gravity.CENTER)
- TV.setTag(t)
- TV.setOnClickListener {
- var position:Int= TV.getTag() as Int//номер ячейки
- }
- tableRow.addView(TV,j)
- t++
- j++
- }
- tblLayout.addView(tableRow,i)
- i++
- }
- }
- <ScrollView
- android:id="@+id/scrollView"
- android:layout_width="match_parent"
- android:layout_weight="60"
- android:orientation="vertical"
- android:background="#ffffff"
- android:layout_height="0dp">
- <TableLayout
- android:id="@+id/tableLayout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
- </ScrollView>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement