I need to create two views programmatically (because I need to access the ondraw of one of the views). For some reason, no matter what I do to add the views to the contentview, they don't show up vertically stacked, one below the other.
I can do it just fine using the XML using a RelativeLayout and layout positioning, but with the XML I can't create a view object and overload the ondraw method.
What am I doing wrong with the programmatic approach, and how do I solve this problem?
LinearLayout mLinearLayout;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create a LinearLayout in which to add the ImageView
mLinearLayout = new LinearLayout(this);
TextView tv = new TextView(this);
tv.setBackgroundColor(0xff333333);
tv.setText("Enter your member number:");
tv.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
DrawableView i = new DrawableView(this);
i.layout(0,40,0,0);
i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
mLinearLayout.addView(tv);
mLinearLayout.addView(i,300,300);
setContentView(mLinearLayout);
}