isAttachedToWindow() returns false

Viewed 1613

Can anyone explain why isAttachedToWindow() is false instead of true? I seem to be having attachment issues.

As I understood it, setContentView(rl) should attach the RelativeLayout to the window. What am I missing?

public class TestActivity extends Activity {
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            final RelativeLayout rl = new RelativeLayout(this);
            setContentView(rl);
            boolean isAttached = rl.isAttachedToWindow();
    }
}
2 Answers
Related