将sd卡中的xml文件设置为android中的布局

时间:2021-12-23 09:00:55

In my application i want to get layout file from server and set that file as content view of activity.I want to know whether it is possible..For this what i had in mind is I'll download file from server and will store it in SD card and will access it from there.But is it possible to set the file as content view..Please help me..

在我的应用程序中,我想从服务器获取布局文件,并将该文件设置为活动的内容视图。我想知道它是否可能。为此,我想到的是我将从服务器下载文件并将其存储在SD卡中,将从那里访问它。但是可以将文件设置为内​​容视图..请帮助我..

1 个解决方案

#1


3  

No,Its not possible.

不,不可能。

To set xml file as layout in your activity you have that file in res/layout directory and also make sure its id entry in R.java files.

要在活动中将xml文件设置为布局,请在res / layout目录中包含该文件,并确保其在R.java文件中的id条目。

Without keeping it in res/layout you can't apply it as a layout to your activity.

如果不将其保留在res / layout中,则无法将其作为布局应用于您的活动。

EDIT:

编辑:

Basically when you put any xml layout file in res/layout then its id entry created in public static final class layout in R.java files, And from there when you set that file as a contentView() of your activity or inflate it, the android nutshell make a view from that raw layout xml file and apply it to your activity.

基本上,当您将任何xml布局文件放在res / layout中时,其id条目在R.java文件中的公共静态最终类布局中创建,并且当您将该文件设置为活动的contentView()或对其进行膨胀时, android nutshell从原始布局xml文件中创建一个视图并将其应用于您的活动。

#1


3  

No,Its not possible.

不,不可能。

To set xml file as layout in your activity you have that file in res/layout directory and also make sure its id entry in R.java files.

要在活动中将xml文件设置为布局,请在res / layout目录中包含该文件,并确保其在R.java文件中的id条目。

Without keeping it in res/layout you can't apply it as a layout to your activity.

如果不将其保留在res / layout中,则无法将其作为布局应用于您的活动。

EDIT:

编辑:

Basically when you put any xml layout file in res/layout then its id entry created in public static final class layout in R.java files, And from there when you set that file as a contentView() of your activity or inflate it, the android nutshell make a view from that raw layout xml file and apply it to your activity.

基本上,当您将任何xml布局文件放在res / layout中时,其id条目在R.java文件中的公共静态最终类布局中创建,并且当您将该文件设置为活动的contentView()或对其进行膨胀时, android nutshell从原始布局xml文件中创建一个视图并将其应用于您的活动。