Questa community è dedicata esclusivamente allo sviluppo di applicazioni per Android.Se state cercando una guida su come rootare il vostro telefono,o su come installare l'ultima Cyanogen, avete sbagliato sito
...... int contatore = 0; final TableLayout tl = (TableLayout)findViewById(R.id.dettaglio); tl.setPadding(5, 0, 0, 0); if (text_to_do.moveToFirst()) { do { contatore=contatore+1; int index = text_to_do.getColumnIndex("testo"); String testo = text_to_do.getString(index); final TableRow tr = new TableRow(this); final TextView casella_testo = new TextView(this); if (contatore%2==0) { tr.setBackgroundColor(getResources().getColor(R.color.pari)); } else { tr.setBackgroundColor(getResources().getColor(R.color.dispari)); } testo = "This is a text - "+contatore + " -"; casella_testo.setText(testo); casella_testo.setWidth(200); casella_testo.setPadding(10, 0, 0, 10); Button butt = new Button(this); butt.setBackgroundResource(R.drawable.try_this); Typeface font = Typeface.createFromAsset(getAssets(), "BAARS___.TTF"); casella_testo.setTextSize(20); casella_testo.setTypeface(font); tr.addView(casella_testo); tr.addView(butt); tr.setGravity(Gravity.CENTER); butt.setHeight(LayoutParams.WRAP_CONTENT); butt.setWidth(LayoutParams.WRAP_CONTENT); butt.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // do something.... startActivity(intent); } }); tr.setPadding(0,10,0,0); tl.addView(tr,new TableLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); } while (text_to_do.moveToNext()); }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:paddingLeft="0dip" android:paddingRight="1dip" android:orientation="vertical"> <ScrollView android:id="@+id/scrllvwNo1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal"> <TableLayout android:id="@+id/dettaglio" android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_gravity="center" android:stretchColumns="0"> </TableLayout> </ScrollView> </LinearLayout>