1
我有一个比较字符串的问题:我得到string.xml中的“激活”的字符串值。当我与具有相同值的字符串值进行比较,结果总是假的(在string.xml激活=测试)getString()string.xml比较
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MyNameApp</string>
<string name="activation">test</string>
</resources>
public class CheckGenuine {
public static String cod;
public static String app;
public static Boolean chk(Context ctx) {
Boolean ret;
cod = ctx.getString(R.string.activation);
app = ctx.getString(R.string.app_name);
if (cod == "test") {
Toast.makeText(ctx, "True cod = " + cod, Toast.LENGTH_LONG).show();
ret = true;}
else {
Toast.makeText(ctx, "False cod = " + cod, Toast.LENGTH_LONG).show();
ret = false;}
// *** why ret is always false and Toast shows "False cod = test" ????????????????
return ret;
}
}
谢谢!我疯了:-) – user1549319 2012-07-24 17:21:15