1. Are you ready for the Galaxy S20? Here is everything we know so far!

Table layout programatically

Discussion in 'Android Development' started by pecmcrl, Sep 1, 2011.

  1. pecmcrl

    pecmcrl Lurker
    Thread Starter

    Hi.......i am new to android development.. Iam trying to create a table layout programatically in the activity it self without using xml file........ Please help to know can i do it.

    Can anyone find the error in following code.....

    import android.app.Activity;
    import android.graphics.Color;
    import android.os.Bundle;
    import android.view.ViewGroup.LayoutParams;
    import android.widget.TableLayout;
    import android.widget.TableRow;
    import android.widget.TextView;

    public class Tablelayout extends Activity{
    public void onCreate(Bundle savedInstanceState){

    LayoutParams params=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);

    TextView tv=new TextView(this);

    TableRow tr=new TableRow(this);

    TableLayout tl=new TableLayout(this);
    TableLayout.LayoutParams layoutparams=new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

    this.addContentView(tl, layoutparams);

    1. Download the Forums for Android™ app!


  2. miXer

    miXer Android Enthusiast

    Is the app crashing? Try to explain some more. If the app is crashing, look in logcat to see what exception is beeing thrown.
  3. pecmcrl

    pecmcrl Lurker
    Thread Starter

    While running its showing error like "the application has stopped unpectedly. please try again" and the logcat showing runtime error message at dalvik.system.NativeStart.man(Native method)
  4. miXer

    miXer Android Enthusiast

    Pasting the whole exception would be of good help

Share This Page