iTwenty
iTwenty

Reputation: 973

Android: Can a view (not a viewgroup) contain another view?

I mean something like this

public class ConditionalEditText extends EditText implements TextWatcher
{
    TextView tv;
    ....
}

The TextView is supposed to be displayed only when the EditText satisfies some user specified condition.

I tried to do it like this

public class ConditionalEditText extends LinearLayout implements TextWatcher
{
    EditText edt;
    TextView tv;
    ....
}

but then I cannot specify different XML attributes for edt for different instances of the view in my main layout.

Upvotes: 0

Views: 550

Answers (2)

iTwenty
iTwenty

Reputation: 973

Turns out there is a way to do this after all. You can anchor a PopupWindow containing any view(s) you want to another View, which is just what I wanted. I got the code to do so from this link and modified it for my needs.

http://code.google.com/p/simple-quickactions/

All thanks to Qberticus for making it!

Upvotes: 0

pskink
pskink

Reputation: 24730

no, only ViewGroup can have child Views

Upvotes: 2

Related Questions