Laden Sie das XML-Layout vom Server (Android)

Ich hatte viele Nachforschungen zu diesem Thema, aber ich habe nicht die gewünschte Antwort erhalten. Ich habe also eine Anwendung, die Zeichenfolge vom Server erhält. Die Zeichenfolge ist im XML-Format.

Hier ist ein Beispiel dafür, was ich vom Server bekommen werde (wie Sie sehen, ist es ein Layout):

<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>

Dies wird abhängig davon geändert, welche XML-Datei vom Server hochgeladen wird. Mein Problem ist, wie ich diese Zeichenfolge in Layout implementieren und als Layout einer Aktivität laden kann. Ich dachte daran, es in einer XML-Datei auf der SD-Karte des Geräts zu speichern und als Layout zu laden, aber ich denke, es ist nicht möglich, den Code nach dem Ausführen neu zu kompilieren. Irgendwelche Vorschläge? Danke.

Antworten auf die Frage(2)

Ihre Antwort auf die Frage