【发布时间】:2014-04-09 23:36:07
【问题描述】:
我对此问题进行了大量研究,但没有得到我想要的答案。 所以我确实有一个应用程序从服务器获取字符串。该系列字符串为 XML 格式。
这是我将从服务器获取的示例(您可以看到它是一个布局):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/number_ref" />
<EditText
android:id="@+id/etTxtNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subject_ref" />
<EditText
android:id="@+id/etTxtSubject"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/body_ref" />
<EditText
android:id="@+id/etTxtBody"
android:layout_width="match_parent"
android:layout_height="200dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/btnTxtSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/save_ref"/>
<Button
android:id="@+id/btnTxtSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/send_ref"/>
<Button
android:id="@+id/btnTxtClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/close_ref"/>
</LinearLayout>
</LinearLayout>
这将根据将从服务器上传的 xml 文件进行更改。我的问题是如何将这些字符串系列实现到布局中并作为活动的布局加载。我正在考虑将它保存在一个 xml 文件中到设备的 sdcard 并将其加载为布局,但我想在运行它之后重新编译代码是不可能的。有什么建议?谢谢。
【问题讨论】:
标签: java android xml android-layout