简体   繁体   中英

Keep getting error attribute is missing the android namspace prefix

Keep getting error attribute is missing the android namspace prefix

I RE EDITED THIS TO SHOW SOME OF THE CODE AS ITS DRIVING ME NUTS

iv edited and changed a few things and still cant work it iv tried adding the android pre fix to the line and nothing yet

re edited

`<games xmlns:android="http://schemas.android.com/apk/res/android">

        <games name="StarCraft"/>
        <games name="RomeTotalWar"/>
        <games name="Half Life"/>
        <games name="Half Life 2" />
        <games name="Sims" />
        <games name="Sims 2" />
        <games name="Sims 3" />
        <games name="Sim City" />

</games>`

I figured out the problem I just cant answer my own questions as of yet but it was simple to figure out after a time really solution is

<games xmlns:android="http://schemas.android.com/apk/res/android">

    <games android:name="StarCraft"/>
    <games android:name="RomeTotalWar"/>
    <games android:name="Half Life"/>
    <games android:name="Half Life 2" />
    <games android:name="Sims" />
    <games android:name="Sims 2" />
    <games android:name="Sims 3" />
    <games android:name="Sim City" />

请使用字符串代替游戏,或者如果代码中存在游戏和游戏类,请在游戏之前提供完整的程序包名称。

You can do this by having the following in array.xml:

<?xml version="1.0" encoding="utf-8"?>  
<resources>
    <string-array name="games">
        <item>StarCraft</item>
        <item>Half Life</item>
        <item>CS</item>
    </string-array>
</resources> 

Then you can call it while creating a adapter, like this:

 private ArrayAdapter adapter2 = ArrayAdapter.createFromResource(this, R.array.doing, android.R.layout.simple_spinner_item);

Since, I don't have the exact idea, where you want to use the adapter, you might need to adapt the code accordingly.

Adding the android namespace to the code itself solved the problem

<games android:name="StarCraft"/>
<games android:name="RomeTotalWar"/>
<games android:name="Half Life"/>
<games android:name="Half Life 2" />
<games android:name="Sims" />
<games android:name="Sims 2" />
<games android:name="Sims 3" />
<games android:name="Sim City" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM