本地化帮助需要java android应用程序

时间:2017-06-14 11:45:49

标签: java android localization

我需要帮助AppConstant.PAYPAL,我需要本地化之后的每一行中的以下java android应用程序的本地化部分

"Withdraw 10$ with PayPal / 10000 Credits"

getString(R.string.pay1)

我添加了

<string name="pay1">Withdraw 10$ with PayPal / 10000 Credits</string>

到我的strings.xml但它失败了

我想要

arr.add(new Reward("res.cloudinary.com/ddtivxyzk/image/upload/v149334941‌​1/…;, AppConstant.PAYPAL, "Withdraw 10$ with PayPal / 10000 Credits", "10000", "10"));

就像:

arr.add(new Reward("res.cloudinary.com/ddtivxyzk/image/upload/v149334941‌​1/…;, AppConstant.PAYPAL, getString(R.string.pay1), "10000", "10"));

但它不起作用

package com.earn.money.db;

import com.earn.money.constant.AppConstant;
import com.earn.money.model.Reward;

import java.util.ArrayList;
import java.util.List;

public class DataProvider {

    public static List<Reward> getRewardList() {
        ArrayList<Reward> arr = new ArrayList<>();

        arr.add(new Reward("http://res.cloudinary.com/ddtivxyzk/image/upload/v1493349411/paypal_e1s9xf.png", AppConstant.PAYPAL, "Withdraw 10$ with PayPal / 10000 Credits", "10000", "10"));
        arr.add(new Reward("http://res.cloudinary.com/ddtivxyzk/image/upload/v1493349411/paypal_e1s9xf.png", AppConstant.PAYPAL, "Withdraw 25$ with PayPal / 25000 Credits", "25000", "25"));
        arr.add(new Reward("http://res.cloudinary.com/ddtivxyzk/image/upload/v1493349411/paypal_e1s9xf.png", AppConstant.PAYPAL, "Withdraw 50$ with PayPal / 50000 Credits", "50000", "50"));

        arr.add(new Reward("http://res.cloudinary.com/ddtivxyzk/image/upload/v1493349714/googleplay_v8rwwu.png", AppConstant.GOOGLE_PLAY, "Gift Card 10$ with Google Play / 10000 Credits", "10000", "10"));
        arr.add(new Reward("http://res.cloudinary.com/ddtivxyzk/image/upload/v1493349714/googleplay_v8rwwu.png", AppConstant.GOOGLE_PLAY, "Gift Card 25$ with Google Play / 25000 Credits", "25000", "25"));
        arr.add(new Reward("http://res.cloudinary.com/ddtivxyzk/image/upload/v1493349714/googleplay_v8rwwu.png", AppConstant.GOOGLE_PLAY, "Gift Card 50$ with Google Play / 50000 Credits", "50000", "50"));

        arr.add(new Reward("http://res.cloudinary.com/ddtivxyzk/image/upload/v1493349711/amazon_eelqab.png", AppConstant.AMAZON, "Gift Card 10$ with Amazon / 10000 Credits", "10000", "10"));
        arr.add(new Reward("http://res.cloudinary.com/ddtivxyzk/image/upload/v1493349711/amazon_eelqab.png", AppConstant.AMAZON, "Gift Card 25$ with Amazon / 25000 Credits", "25000", "25"));
        arr.add(new Reward("http://res.cloudinary.com/ddtivxyzk/image/upload/v1493349711/amazon_eelqab.png", AppConstant.AMAZON, "Gift Card 50$ with Amazon / 50000 Credits", "50000", "50"));

        arr.add(new Reward("http://res.cloudinary.com/ddtivxyzk/image/upload/v1493349709/webmoney_jptfkw.jpg", AppConstant.WEBMONEY, "Withdraw 10$ with WebMoney / 10000 Credits", "10000", "10"));
        arr.add(new Reward("http://res.cloudinary.com/ddtivxyzk/image/upload/v1493349709/webmoney_jptfkw.jpg", AppConstant.WEBMONEY, "Withdraw 25$ with WebMoney / 25000 Credits", "25000", "25"));
        arr.add(new Reward("http://res.cloudinary.com/ddtivxyzk/image/upload/v1493349709/webmoney_jptfkw.jpg", AppConstant.WEBMONEY, "Withdraw 50$ with WebMoney / 50000 Credits", "50000", "50"));

        return arr;
    }

 }

2 个答案:

答案 0 :(得分:0)

你需要这个

context.getResources().getString(R.string.pay1)

但请显示您的错误日志。

答案 1 :(得分:0)

通过添加解决问题 import com.earn.money.R 到java文件 感谢所有回答我并试图帮助我的人