You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
api-impl/android/view/LayoutInflater.java: load layout XMLs directly from apk
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.XmlResourceParser;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Xml;
|
import android.util.Xml;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
@@ -87,15 +88,7 @@ public class LayoutInflater {
|
|||||||
|
|
||||||
public View inflate(int layoutResID, ViewGroup root, boolean attachToRoot) throws Exception {
|
public View inflate(int layoutResID, ViewGroup root, boolean attachToRoot) throws Exception {
|
||||||
|
|
||||||
String layout_xml_file = android.os.Environment.getExternalStorageDirectory().getPath() + "/" + Context.this_application.getString(layoutResID);
|
XmlResourceParser xpp = Context.this_application.getResources().getLayout(layoutResID);
|
||||||
|
|
||||||
System.out.println("loading layout from: " + layout_xml_file);
|
|
||||||
|
|
||||||
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
|
|
||||||
factory.setNamespaceAware(true);
|
|
||||||
XmlPullParser xpp = factory.newPullParser();
|
|
||||||
|
|
||||||
xpp.setInput(new FileReader(layout_xml_file));
|
|
||||||
|
|
||||||
return inflate(xpp, root, attachToRoot);
|
return inflate(xpp, root, attachToRoot);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user