praegune kellaaeg 17.06.2025 16:50:08
|
Hinnavaatlus
:: Foorum
:: Uudised
:: Ärifoorumid
:: HV F1 ennustusvõistlus
:: Pangalink
:: Telekavad
:: HV toote otsing
|
|
autor |
|
kevin3220
HV vaatleja
liitunud: 31.10.2011
|
02.07.2014 14:25:02
Android EditText TextViewi alla |
|
|
Tere
Selline probleem, et mul oleks vaja saada EditText siia alla:
Kood:
package com.example.tablefreezepane;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.widget.EditText;
import android.widget.HorizontalScrollView;
import android.widget.ScrollView;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
public class asd extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] row = { " 1 ", " 2 ", " ", " 4 ", " 5 ", " 6 ",
" 9 "};
String[] column = { " 1 ",
" 2 ",
" 3 ",
" 4 ",
" 5 "};
int rl=row.length+1; int cl=column.length+1;
ScrollView sv = new ScrollView(this);
TableLayout tableLayout = createTableLayout(row, column,rl, cl);
HorizontalScrollView hsv = new HorizontalScrollView(this);
hsv.addView(tableLayout);
sv.addView(hsv);
setContentView(sv);
setHeaderTitle(tableLayout,1,1,"TEXT / ID\nNR");
}
// X JA Y
public void makeCellEmpty(TableLayout tableLayout, int rowIndex, int columnIndex) {
// get row from table with rowIndex
TableRow tableRow = (TableRow) tableLayout.getChildAt(rowIndex);
// get cell from row with columnIndex
TextView textView = (TextView)tableRow.getChildAt(columnIndex);
// make it black
textView.setBackgroundColor(Color.WHITE);
}
public void setHeaderTitle(TableLayout tableLayout, int rowIndex, int columnIndex,String name){
// get row from table with rowIndex
TableRow tableRow = (TableRow) tableLayout.getChildAt(rowIndex);
// get cell from row with columnIndex
TextView textView = (TextView)tableRow.getChildAt(columnIndex);
textView.setText(name);
}
private TableLayout createTableLayout(String [] rv, String [] cv,int rowCount, int columnCount) {
// 1) Create a tableLayout and its params
TableLayout.LayoutParams tableLayoutParams = new TableLayout.LayoutParams();
TableLayout tableLayout = new TableLayout(this);
tableLayout.setBackgroundColor(Color.YELLOW);
// 2) create tableRow params
TableRow.LayoutParams tableRowParams = new TableRow.LayoutParams();
tableRowParams.setMargins(1, 1, 1, 1);
tableRowParams.weight = 1;
for (int i = 0; i < rowCount; i++) {
// 3) create tableRow
TableRow tableRow = new TableRow(this);
tableRow.setBackgroundColor(Color.BLACK);
EditText edt=new EditText(this);
for (int j= 0; j < columnCount; j++) {
// 4) create textView
TextView textView = new TextView(this);
// textView.setText(String.valueOf(j));
textView.setBackgroundColor(Color.WHITE);
textView.setGravity(Gravity.CENTER);
edt.setGravity(Gravity.BOTTOM);
String s1 = Integer.toString(i);
String s2 = Integer.toString(j);
String s3 = s1 + s2;
int id = Integer.parseInt(s3);
Log.d("TAG", "-___>"+id);
if (i ==0 && j==0){
edt.setText("hi");
textView.setText("0==0");
} else if(i==0){
Log.d("TAAG", "set Column Headers");
textView.setText(cv[j-1]);
}else if( j==0){
Log.d("TAAG", "Set Row Headers");
textView.setText(rv[i-1]);
}else {
textView.setText(""+id);
// check id=23
if(id==23){
textView.setText("ID=23");
}
}
// 5) add textView to tableRow
tableRow.addView(textView, tableRowParams);
}
// 6) add tableRow to tableLayout
tableLayout.addView(tableRow, tableLayoutParams);
}
return tableLayout;
}
}
|
|
|
tagasi üles |
|
 |
Donald
HV kasutaja

liitunud: 25.03.2003
|
02.07.2014 16:01:04
|
|
|
public void setHeaderTitle(TableLayout tableLayout, int rowIndex, int columnIndex, String name) {
...
...
...
TextView sinuText = new TextView(this);
tableRow.addView(sinuText);
} |
Midagi nii umbes?
|
|
Kommentaarid: 10 loe/lisa |
Kasutajad arvavad: |
   |
:: |
0 :: |
1 :: |
9 |
|
tagasi üles |
|
 |
|
lisa lemmikuks |
|
|
sa ei või postitada uusi teemasid siia foorumisse sa ei või vastata selle foorumi teemadele sa ei või muuta oma postitusi selles foorumis sa ei või kustutada oma postitusi selles foorumis sa ei või vastata küsitlustele selles foorumis sa ei saa lisada manuseid selles foorumis sa võid manuseid alla laadida selles foorumis
|
|
Hinnavaatlus ei vastuta foorumis tehtud postituste eest.
|