2

I used include layout in my android project to load another activity to main activity but include layout just load xml file and not load java code related to activity.

How to i can load both xml and java file code ?

<include
    android:id="@+id/include2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentBottom="true"
    layout="@layout/actfooter" />
4
  • 1
    post your code, its not clear question Commented Jan 2, 2014 at 7:21
  • What exactly are you trying to accomplish? Commented Jan 2, 2014 at 7:27
  • Are you asking about including layout inside another layout? Commented Jan 2, 2014 at 7:33
  • i want to include an activity (such xml and java file) to another activity Commented Jan 2, 2014 at 7:44

2 Answers 2

1

Just include the layout by using <include> tag

just extends the activity with your current activity.

For ex- class MainAcitivity extends includeAcitivity to work with the code of your includeActivity.

Sign up to request clarification or add additional context in comments.

4 Comments

thankyou; but if i have several include how to i do it ?
can you describ more or give a link
@HamidTB have you heard about Fragments? this is you are looking for
@HamidTB you can also use fragment to make multiple includes developer.android.com/training/basics/fragments/creating.html
0

boss as you use <include> tag that means you are inflating the view part and the xml you are inflating in your layout will be accessible in your activity.

You have to write code in activity in which you are inflating.

as per your expectation you must use fragments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.