Friday, September 21, 2012

[android-developers] Adding a ViewGroup to RelativeLayout

I want a RelativeLayout that's composed of two parts: The bottom portion is an xml TableLayout file, and the top portion, which i plan to do later, will be a separate custom view. 
So far i tried to add the TableLayout to the RelativeLayout and am already getting an error.

public class mainActivity extends Activity{
RelativeLayout relativeLayout;
TableLayout tableLayoutl;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
relativeLayout=new RelativeLayout(this);
ViewGroup vg= (ViewGroup)findViewById(R.layout.myTableLayout);
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
relativeLayout.addView(vg,relativeParams);
setContentView(relativeLayout);
}
}
I feel like there is a much easier way to do this, any help? 

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment