I want to use ViewStub in android, so please help me. I have created
ViewStub stub = new ViewStub;
View inflated = stub.inflate();
How to use it programmatically?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Like the documentation says,
ViewStubis aViewthat is inflated lazily.You can declare a
ViewStubin an XML file like this:The
android:layoutattribute is a reference to theViewthat will be inflated next to a call ofinflate(). SoWhen the method
inflate()is invoked theViewStubis removed from its parent and replaced with the rightView(the root view ofmySubTreelayout).If you want to do this progammatically then your code should be something like: