Hi all,
I've generated table layout dynamically.But nothing displays in the
activity.
My program is below.
I am beginner in Android.I don't know where the problem is?
Please help me.
package com.maag.tableproject;
import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup.LayoutParams;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
public class TableProjectActivity extends Activity {
/** Called when the activity is first created. */
TableLayout tble;
TableRow tbr;
TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv= new TextView(this);
tv.setText("This is text View");
tv.setLayoutParams(new
LayoutParams(TableRow.LayoutParams.FILL_PARENT,
TableRow.LayoutParams.WRAP_CONTENT));
tv.setId(10);
tbr= new TableRow(this);
tbr.setLayoutParams(new
LayoutParams(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT));
tbr.addView(tv);
tble=(TableLayout)findViewById(R.id.table);
tble.addView(tbr,new
LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT ));
// setContentView(tble);
}
}
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/table"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TableLayout>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en