getString()がidの文字列ではなく別の文字列を返すという問題に直面しています。しかし、最初にここに私のコードです:Android getString()が間違った文字列を返します
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を返すことであり、 )は「リーダーボード」を返します。私はこれをどのように修正するのか分かりません。なぜこれが起こるのかはかなり混乱しています。私は間違って何をしていますか?これは動作するはず
headlineName.setText(getResources().getString(R.string.shop_headline_name));
:あなたの答え
プロジェクトをクリーンアップしてください(Androidスタジオで[ビルド]> [プロジェクトをクリーンアップ]など)。 – CommonsWare
**インスタント・ラン**が有効になっていると、それが原因である可能性があります。それはまだ壊れたものです、それを使用しないでください! – Sufian