導航:首頁 > 源碼編譯 > 如何增加xml資源碼

如何增加xml資源碼

發布時間:2022-09-28 12:25:08

① C#怎麼把.xml文件生成嵌入資源。.xml文件我已經寫好了,要怎麼樣把它生成嵌入資源文件。說下操作步驟

選擇這個xml文件,右擊-屬性--嵌入的資源就行了

② .請簡述如何在java代碼與XML文件中調用布局資源文件

步驟:
1、在存放使用資源的res文件夾下的layout文件夾內新建一個XML布局文件,如命名為:page1.xml。
2、在存放資、代碼的文件夾下下找到MainActivity.java,雙擊打開,在onCreate的方法內添加關聯代碼。

③ web.xml 怎麼添加web.xml

首先創建一個類
public class ContextInitListener implements ServletContextListener
使得該類成為一個監聽器。用於監聽整個容器生命周期的,主要是初始化和銷毀的。
類創建後要在web.xml配置文件中增加一個簡單的監聽器配置,即剛才我們定義的類。
Xml代碼

<listener>
<!-- lang: xml -->
<description>ServletContextListener</description>
<!-- lang: xml -->
<listener-class>com.test.web.filter.ContextInitListener</listener-class>
<!-- lang: xml -->
</listener>

配置好監聽器後我們開始編寫ContextInitListener 的代碼。實現介面後會自動生成兩個方法,初始化和銷毀,我們就只貼出這個吧,另一個沒什麼用。web項目通常來說,一般來說相對路徑是在WEB-INF/classes,獲取該路徑下的文件,最好用getClass().getResourceAsStream(「/baseconfig.properties」);比較簡單。
Java代碼

@Override
public void contextInitialized(ServletContextEvent sce) {
Properties props = new Properties();
InputStream inputStream = null;
try {
inputStream = getClass().getResourceAsStream("/baseconfig.properties");
props.load(inputStream);
String tempPath = (String) props.get("path");
} catch (IOException ex) {
ex.printStackTrace();
}
}

④ 如何為android系統添加一個新的資源包

具體做法可以分為以下幾個步驟:

1. 修改build/core/clear_var.mk

LOCAL_USE_LETV_FRAMEWORK_RES:= true

2. 修改build/core/package.mk

以下腳本可以加在 $(R_file_stamp): $(framework_res_package_export_deps) 之前,然後修改$(R_file_stamp): $(framework_res_package_export_deps) 和 $(LOCAL_INTERMEDIATE_TARGETS): \
PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)

如下所示:

view sourceprint?
1 ifeq ($(LOCAL_USE_LETV_FRAMEWORK_RES),true)

2 letv_framework_res_package_export := \

3 $(call intermediates-dir-for,APPS,letv-framework-res,,COMMON)/package-export.apk

4 letv_framework_res_package_export_deps := \

5 $(dir $(letv_framework_res_package_export))src/R.stamp

6 else

7 letv_framework_res_package_export :=

8 letv_framework_res_package_export_deps :=

9 endif # LOCAL_USE_LETV_FRAMEWORK_RES
view sourceprint?
1 $(R_file_stamp): $(framework_res_package_export_deps) $(letv_framework_res_package_export_deps)

2 $(LOCAL_INTERMEDIATE_TARGETS): \

3 PRIVATE_AAPT_INCLUDES := $(framework_res_package_export) \

4 $(letv_framework_res_package_export)

5 endif # LOCAL_NO_STANDARD_LIBRARIES
3. 修改build/target/proct/core.mk

在PRODUCT_PACKAGES增加letv-framework-res

4. 添加一個新的資源包項目,這里在framework/base/core/res同級目錄下建立一個新的文件夾letv_res用來存放咱們的資源。把res目錄下的AndroidManifest.xml和Android.mk拷貝過來,進行修改。

記得設置LOCAL_USE_MY_FRAMEWORK_RES為false。

view sourceprint?
01 LOCAL_PATH:= $(call my-dir)

02 include $(CLEAR_VARS)

03

04 LOCAL_MODULE_TAGS := optional

05

06 LOCAL_PACKAGE_NAME := letv-framework-res

07 LOCAL_CERTIFICATE := platform

08

09 # Set LOCAL_USE_LETV_FRAMEWORK_RES as false

10 LOCAL_USE_LETV_FRAMEWORK_RES := false

11

12 # Tell aapt to create "extending (non-application)" resource IDs,

13 # since these resources will be used by many apps.

14 LOCAL_AAPT_FLAGS := -x

15

16 # Install this alongside the libraries.

17 LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)

18

19 # Create package-export.apk, which other packages can use to get

20 # PRODUCT-agnostic resource data like IDs and type definitions.

21 LOCAL_EXPORT_PACKAGE_RESOURCES := true

22

23 # Include resources generated by system RenderScript files.

24 framework_GENERATED_SOURCE_DIR := $(call intermediates-dir-for,JAVA_LIBRARIES,framework,,COMMON)/src

25 framework_RenderScript_STAMP_FILE := $(framework_GENERATED_SOURCE_DIR)/RenderScript.stamp

26 #LOCAL_RESOURCE_DIR := $(framework_GENERATED_SOURCE_DIR)/renderscript/res $(LOCAL_PATH)/res

27

28 include $(BUILD_PACKAGE)

29

30 # Make sure the system .rs files get compiled before building the package-export.apk.

31 #$(resource_export_package): $(framework_RenderScript_STAMP_FILE)

32

33 # define a global intermediate target that other mole may depend on.

34 .PHONY: letv-framework-res-package-target

35 letv-framework-res-package-target: $(LOCAL_BUILT_MODULE)

view sourceprint?
01 <?xml version="1.0" encoding="utf-8"?>

02 <manifest xmlns:android=""

03 package="letv" coreApp="true" android:sharedUserId="android.uid.system"

04 android:sharedUserLabel="@null">

05

06 <application android:process="system"

07 android:persistent="true"

08 android:hasCode="false"

09 android:label="@null"

10 android:allowClearUserData="false"

11 android:killAfterRestore="false"

12 android:icon="@null">

13

14 </application>

15

16 </manifest>

資源的放置跟res下的類似,記得values目錄下創建public.xml,public.xml對id的類型區分比較嚴格,attr必須是0x0x010000開頭,drawable必須是0x0x020000開頭,其他類型好像就沒有限制,直接依次0x0x030000、0x0x040000開始即可。否則,編譯過程中會出現segmentation fault錯誤。

view sourceprint?
1 <resources>

2 <public type="attr" name="cForeground" id="0x03010000" />

3 <public type="drawable" name="ic_filemanager" id="0x03020000" />

4 <public type="style" name="LetvTheme" id="0x03030000" />

5 <public type="string" name="letv" id="0x03040000" />

6 <public type="dimen" name="letv_width" id="0x03050000" />

7 <public type="layout" name="letv_text" id="0x03060000" />

8 </resources>
5. 以上只是解決了資源的編譯環境問題,資源的查找過程也需要進行修改,修改 AssetManager.java,在init()後添加代碼 addAssetPath("/system/framework/letv-framework-res.apk");
view sourceprint?
01 public AssetManager() {

02 synchronized (this) {

03 if (DEBUG_REFS) {

04 mNumRefs = 0;

05 incRefsLocked(this.hashCode());

06 }

07 init();

08 addAssetPath("/system/framework/letv-framework-res.apk");

09 if (localLOGV) Log.v(TAG, "New asset manager: " + this);

10 ensureSystemAssets();

11 }

12 }

6. 最後就是資源應用問題。應用程序在xml文件中引用letv-framework-res.apk中的資源時可以使用與原生資源類似的訪問方式,首先聲明letv xmlns :

view sourceprint?
1 xmlns:letv=""
然後像@android:drawable @android:dimen這種引用方式改成@letv:drawable @letv:dimen即可。

view sourceprint?
01 <?xml version="1.0" encoding="utf-8"?>

02 <LinearLayout

03 xmlns:android=""

04 xmlns:letv=""

05 android:layout_width="fill_parent"

06 android:layout_height="wrap_content"

07 android:gravity="center"

08 android:paddingTop="@letv:dimen/letv_width"

09 android:orientation="horizontal" >

10

11 <ImageView android:id="@+id/file_icon"

12 android:layout_width="wrap_content"

13 android:layout_height="wrap_content"

14 android:layout_gravity="center"

15 android:layout_marginBottom="40dp"

16 android:src="@letv:drawable/ic_filemanager" />

17

18 </LinearLayout>

⑤ Android studio怎麼創建資源的相關文件編輯xml

1、要進行創建資源文件之前,需要先把滑鼠代碼的文件中進行選中,或者進行選中項目。

2、然後點擊菜單中菜單中的」file「的選項。

3、就會彈出了一個下拉的菜單中,進行選擇下拉菜單中的「new」的選項按鈕。

4、這樣就會彈出了一個下一級的菜單中,進行選擇菜單中的「Android resource file」的選項。

5、然後就會彈出了一個new resource file的選項,進入輸入一個file name的文件名,在available qualifiers的進行選擇layout direction進行點擊雙箭頭,然後就可以點擊」OK「。

6、這樣話在Android studio的資源文件就創建成功了。

⑥ xml資源文件如何使用

xml資源文件如何使用 這個問題很簡單。xml資源文件你可以使用它來保存任何數據信息,它就像資料庫保存數據一樣,都是持久化的。在.net開發中,對xml文件的操作是必不可少的,而且微軟也一直提升對xml文件操作的加強技術,從.net2.0的XmlReader和XmlWriter到.net 3.5 的linq to xml來操作xml操作。在.net開發中,你可以把xml放到App_Data文件夾中,這樣更安全。在這里我推薦使用linq to xml 來操作xml文件,linq to xml 可以提供高效率的代碼來對xml文件進行查增刪改操作。對於利用XmlReader和XmlWriter以及linq to xml 來操作xml的代碼如何編寫這里我就不一一詳述了,你可以在網上搜索,很多的,希望我的回答和建議對你有用,謝謝。
我剛看到你的問題補充,所以我在這里接著這個問題進行補充:
我仔細看過你給的鏈接地址網頁和你的截圖圖片,我明白了你問題的意思:
在你的文件中有很多xml文件,每一個xml文件相當於你可以添加的一個功能,比如你要添加音樂,那你就在music.xml文件里修改代碼來添加上你需要播放的音樂,例如你要添加一個mp3叫做我愛你.mp3,那你就在<musicList><music caption="我愛你.mp3" src="resource/res/music/我愛你.mp3"><musicList>就可以了,當然你首先要把我愛你.mp3這個文件放到resource/res/music/目錄裡面,然後設置一下config.xml文件,具體的做法按照它顯示出來的那樣設置就可以了。希望你能明白我的意思,我是程序開發的,希望我的回答能幫助上你,謝謝。

⑦ 如何在html中插入xml

實例!
以下是XML文件【1.xml】內容:
<?xml version="1.0" encoding="gb2312"?>
<config>
<content>
<content_1>1.我的內容1.</content_1>
<content_2>2.我的內容2.</content_2>
</content>
</config>

以下是ASP文件內容【1.asp 用於管理1.xml】:
<%
strSourceFile = Server.MapPath("1.xml")
Set objXML = Server.CreateObject("Microsoft.XMLDOM") '創建一個XML對像
'Set objXML = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
objXML.load(strSourceFile) '把XML文件讀入內存
If objXML.parseError.ErrorCode <> 0 Then
objXML.loadXML "<?xml version=""1.0"" encoding=""gb2312"" ?>"
End If
set objcontent = objXML.documentElement.SelectSingleNode("content") '讀取節點content
if request("tijiao")="yes" then '判斷是否是提交過來的
objcontent.SelectSingleNode("content_1").text=request.form("content_1")
objcontent.SelectSingleNode("content_2").text=request.form("content_2")
objXML.save(strSourceFile) '將提交過來的表單數據寫入XML
response.Write("<script>alert('保存成功!');</script>")
end if
%>
<html><head>
<TITLE>XML文件讀寫實例</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body>
<table width=98% align="center" border="1" cellspacing="0" cellpadding="4" style="border-collapse: collapse">
<form name="form1" method="post" action="">
<input type="hidden" value="yes" name="tijiao"> <!--這里一個隱形的input用於提交判斷-->
<tr><td height=25>XML文件讀寫實例</td></tr>
<tr>
<td>內容1: <input name="content_1" type="text" id="content_1" value="<%=objcontent.SelectSingleNode("content_1").text%>" size="60">
</td>
<tr>
<td>內容2: <input name="content_2" type="text" id="content_2" value="<%=objcontent.SelectSingleNode("content_2").text%>" size="60">
</td>
</tr>
<tr align="center">
<td height="36">
<input type="submit" name="Submit" value="保存">
</td>
</tr> </form>
</table>
</body>
</html>

被調用顯示文檔也使用ASP,參照input內顯示的值!

閱讀全文

與如何增加xml資源碼相關的資料

熱點內容
有一個電影男主叫馬克 瀏覽:779
韓國,補課電影演員表 瀏覽:182
linux查看系統命令是什麼 瀏覽:32
matlab歷史命令 瀏覽:219
主角穿越到工作細胞的小說 瀏覽:102
九十年代香港老太太鬼電影 瀏覽:871
特工劉堅是李連傑的哪部電影 瀏覽:334
極坐標運演算法則 瀏覽:605
十大香港全漏電影 瀏覽:335
小虎還鄉裡面的驢叫什麼 瀏覽:499
誰有小電影網址啊 瀏覽:376
香港滿清十大酷刑一共有幾部電影 瀏覽:709
icloud發件伺服器埠是什麼 瀏覽:572
天殘腳電影 瀏覽:335
十部必看剿匪電影 瀏覽:692
免費台灣理論 瀏覽:132
大地影院明天有什麼電影 瀏覽:483
金石學pdf 瀏覽:696
河南天工集團廣訊通伺服器地址 瀏覽:420
cad制圖常用命令 瀏覽:857