我遇到了一个问题,即getString()方法返回的不是id对应的字符串,而是另一个字符串。这是我的代码:
public public class ShopFragment extends Fragment {
...
public class ShopManager(){
...
private TableRow[] getRowsFromItems(){
...
TextView headlineName = new TextView(getContext());
headlineName.setText(getString(R.string.shop_headline_name));
TextView headlinePrice = new TextView(getContext());
headlinePrice.setText(getString(R.string.shop_headline_price));
...
}
}
}
strings.xml:
<resources>
...
<string name="show_leaderboards">Leaderboards</string>
<string name="show_achievements">Achievements</string>
...
<string name="shop_headline_name">Article</string>
<string name="shop_headline_price">Price</string>
...
</resources>
问题是,getString(R.string.shop_headline_name)返回的是“成就”,getString(R.string.shop_headline_price)返回的是“排行榜”。我不知道如何解决这个问题,也很困惑为什么会发生这种情况。我做错了什么吗? 感谢您的答复。