FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

about resources · withyou/AndroidDynamicLoader@8cea6cf · GitHub

Repository navigation

Commit 8cea6cf

Browse files
committed
about resources
1 parent fb9dd1c commit 8cea6cf

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,33 @@ Each host is mapped to a single fragment, you define the url mapping table in **
4646

4747
See the [helloworld fragment.properties](https://github.com/mmin18/AndroidDynamicLoader/blob/master/workspace/sample.helloworld/fragment.properties) sample.
4848

49+
## About Resources
50+
51+
In the plugins, we pack resources and codes in the same package. We use R.java as the index of resources.
52+
53+
But instead of using **context.getResources()**, we use **MyResources.getResource(Me.class)** to get the resources which in the same package as **Me.class**.
54+
55+
Here is a sample in HelloFragment.java
56+
57+
@Override
58+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
59+
Bundle savedInstanceState) {
60+
61+
// MyResources manages the resources in specific package.
62+
// Using a Class object to obtain an instance of MyResources.
63+
64+
// In this case, hello.xml is in the same package as HelloFragment class
65+
66+
MyResources res = MyResources.getResource(HelloFragment.class);
67+
68+
// Using MyResources.inflate() if you want to inflate some layout in
69+
// this package.
70+
return res.inflate(getActivity(), R.layout.hello, container, false);
71+
72+
}
73+
74+
You can use MyResources to get drawable, string, or inflate layout.
75+
4976
## Folders
5077

5178
`/Host` contains the host application (build as host.apk).

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL