Restoring code that reads the strings.xml file, merging indeed's changes

This commit is contained in:
Joe Bowser 2009-02-25 13:54:13 -08:00
parent fb341b7428
commit 85d98b34be
3 changed files with 23 additions and 10 deletions

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, PhoneGap</string>
<string name="app_name">PhoneGap</string>
<string name="url">http://phonegap.com/demo2/</string>
<string name="url">file:///android_asset/index.html</string>
</resources>

View File

@ -4,7 +4,7 @@ package com.nitobi.phonegap;
* website: http://phonegap.com
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* Software), to deal in the Software without restriction, including
* Software), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
@ -13,7 +13,7 @@ package com.nitobi.phonegap;
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
@ -22,6 +22,8 @@ package com.nitobi.phonegap;
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import java.lang.reflect.Field;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
@ -59,9 +61,22 @@ public class DroidGap extends Activity {
/* Bind the appView object to the gap class methods */
bindBrowser(appView);
appView.loadUrl("file:///android_asset/index.html");
/* Load a URI from the strings.xml file */
String uri = null;
Class<R.string> c = R.string.class;
Field f;
int i = 0;
try {
f = c.getField("url");
i = f.getInt(f);
uri = this.getResources().getString(i);
} catch (Exception e)
{
uri = "http://www.phonegap.com";
}
appView.loadUrl(uri);
}

View File

@ -25,8 +25,7 @@ public final class R {
public static final int on=0x7f040002;
}
public static final class string {
public static final int app_name=0x7f050001;
public static final int hello=0x7f050000;
public static final int url=0x7f050002;
public static final int app_name=0x7f050000;
public static final int url=0x7f050001;
}
}