Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android NumberFormatException:无效的int:"&引用;_Android_Android Recyclerview_Localization_Numberformatexception_Parseint - Fatal编程技术网

Android NumberFormatException:无效的int:"&引用;

Android NumberFormatException:无效的int:"&引用;,android,android-recyclerview,localization,numberformatexception,parseint,Android,Android Recyclerview,Localization,Numberformatexception,Parseint,在我的应用程序中,我正在进行语言本地化。它与按钮和文本视图完美配合,但无法更改recyclerview上的字符串 上面说 NumberFormatException:无效的int:“ private void updateViews(字符串语言代码){ Context Context=LocaleHelper.setLocale(MainActivity.this,languageCode); Resources=context.getResources(); changelang.setTe

在我的应用程序中,我正在进行语言本地化。它与按钮和文本视图完美配合,但无法更改recyclerview上的字符串

上面说 NumberFormatException:无效的int:“

private void updateViews(字符串语言代码){
Context Context=LocaleHelper.setLocale(MainActivity.this,languageCode);
Resources=context.getResources();
changelang.setText(resources.getString(R.string.changelanguage));
setText(resources.getString(R.string.languagename));
//以下行object01.setDepname(Integer.parseInt(resources.getString(R.string.culturation))出错;
}

});您正在尝试将资源中的字符串转换为整数值。这是不可能的! 要支持多种语言,请使用所需的语言环境创建一个新的string.xml


尝试将资源中的字符串转换为整数值时,请参见。这是不可能的,所以尝试这样更改模型类

public class ContentsDep {
    int depimage;
    String depname;

    public int getDepimage() {return depimage;
    }

    public void setDepimage(int depimage) {this.depimage = depimage;
    }

    public void setDepname(String depname) {
        this.depname = depname;
    }

    public String getDepname() {return depname;}

}
object01.setDepname(resources.getString(R.string.cultivation));
然后像这样设置值

public class ContentsDep {
    int depimage;
    String depname;

    public int getDepimage() {return depimage;
    }

    public void setDepimage(int depimage) {this.depimage = depimage;
    }

    public void setDepname(String depname) {
        this.depname = depname;
    }

    public String getDepname() {return depname;}

}
object01.setDepname(resources.getString(R.string.cultivation));

我已经为这两种语言创建了string.xmls,并将其用于按钮名称和文本视图。但从回收商的角度来看,这是不可能的。那么,在这种情况下,我应该怎么做呢?我已经在模型类中将文本定义为int,字符串文件中的
值是多少?这是一个数字吗?没有印地语文本,如下所示खेती那你为什么要把它转换成
int
?我也试过用字符串,你能检查一下我以前的帖子吗?好的,提供一个链接。事实上,兄弟,我以前试过这个。但是它产生了一个新问题。事实上,兄弟,我以前试过这个。但是它产生了一个新问题final contents dp object01=new contents dp();object01.setDepname(R.string.variates)//在这一行中,它显示了一个“内容中的setDepname不能应用于int”,所以我只是对string进行了修改,然后我还必须在适配器类中对其进行更改。然后在执行之后,它显示了一个长数字,而不是string name