How do I view a second xml layout beside the main layout with click button listener. And to get some variable in that layout? Sory this beginner question, but I cannot find the similar question in stackoverflow.
            Asked
            
        
        
            Active
            
        
            Viewed 635 times
        
    3 Answers
3
            If you want to put another layout from other XML inside the one you already have, you could use LayoutInflater too.
// Get the layout inflater
LayoutInflater inflater = (LayoutInflater) context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// Get the view
View view = inflater.inflate(R.layout.other_layout, null);
[]'s
        Felipe Vasconcelos
        
- 2,067
 - 1
 - 22
 - 29
 
1
            
            
        If you want to show another layout beside the current one, you should use Fragments. See the links below to some explanation.
http://developer.android.com/guide/components/fragments.html
http://developer.android.com/training/basics/fragments/creating.html
http://www.vogella.com/tutorials/AndroidFragments/article.html
        ansorod
        
- 367
 - 1
 - 5
 
1
            
            
        Inflate the "second" layout (second_layout.xml):
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Get the View:
View view = inflater.inflate(R.layout.second_layout, null);
Get an element inside the second_layout.xml, for example if you have a TextView with  android:id="@+id/txtview_description":
TextView myTextView = (TextView)view.findViewById(R.id.txtview_description);
        Jorgesys
        
- 124,308
 - 23
 - 334
 - 268