简体   繁体   中英

How can I refer to layout/xml files of another project from my Activity class in Android?

I have two Android projects in my Workspace. Now, I want to access the res/layout files of second project in the activity/Java class of my first project.

I have already added the second project as a library of first project but its not working. Do I need to give the path in setContentView(R.layout.main) or something like that. Please suggest.

FYI: I am working on 4.2 version of Android.

Regards, Anupriya

我已尝试使用相同的结果你可以直接访问布局文件及其名称添加库后请清理项目,然后尝试从另一个项目的资源文件夹中访问文件,即

setContentView(R.layout.layout_from_other_project);

You probably would need to add your own uri for library and use it to refer to drawable.

xmlns:libProj="http://schemas.android.com/apk/res/com.test.mylib"

Then you should be able to access drawable using

@libProj:drawable/myImage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM