| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,33 @@ Each host is mapped to a single fragment, you define the url mapping table in ** | |||
| 46 | 46 | ||
| 47 | 47 | See the [helloworld fragment.properties](https://github.com/mmin18/AndroidDynamicLoader/blob/master/workspace/sample.helloworld/fragment.properties) sample. | |
| 48 | 48 | ||
| 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 | + | ||
| 49 | 76 | ## Folders | |
| 50 | 77 | ||
| 51 | 78 | `/Host` contains the host application (build as host.apk). | |
| Back | FazBrowse Home | New Git URL |
0 commit comments