简体   繁体   English

找不到资源 字符串资源 ID

[英]Resource not found String resource ID

I am making an which app which have 2 android project;我正在制作一个有 2 个 android 项目的应用程序; 1st project is library project and 2nd project is my main project.第一个项目是图书馆项目,第二个项目是我的主要项目。 project-1 is working fine but when I am adding it in my Project-2 as library it is giving me exceptions like this Resource not found String resource ID #0x76000456 project-1 工作正常,但是当我将它添加到我的 Project-2 作为库时,它给了我这样的异常Resource not found String resource ID #0x76000456

when i checked my string bundle and R.java this string is there.当我检查我的字符串包和 R.java 时,这个字符串就在那里。

I have tried clean Project restart my eclipse and my system.我已经尝试过干净的项目重新启动我的 Eclipse 和我的系统。

my strings.xml file looks like:-我的 strings.xml 文件看起来像:-

 <string name="pref_loadrecent_id">loadrecent</string>
<string name="pref_loadrecent_defvalue">false</string>

<string name="pref_confirmclose_id">confirmclose</string>
<string name="pref_confirmclose_defvalue">false</string>

and I am calling like this:-我是这样打电话的:-

BooleanPreferenceDefinition LOAD_RECENT = new BooleanPreferenceDefinition(pref_loadrecent_id,
        pref_loadrecent_defvalue);

BooleanPreferenceDefinition CONFIRM_CLOSE = new BooleanPreferenceDefinition(pref_confirmclose_id,
        pref_confirmclose_defvalue);

and I am doing static import of R.string like this我正在像这样静态导入 R.string

import static com.ankit.R.string.*;

For testing instead of calling from string id i hard code the values of pref_loadrecent_id and pref_loadrecent_defvalue then it is showing similar exception(with different ID) for pref_confirmclose_id and pref_confirmclose_defvalue .为了测试而不是从字符串ID调用我硬编码的值pref_loadrecent_idpref_loadrecent_defvalue然后将其示出了用于类似的异常(具有不同的ID) pref_confirmclose_idpref_confirmclose_defvalue

Please help me out.请帮帮我。

The parameter which you are passing for your answer might not converted into string ... first convert it into string then pass that string parameter for correct answer..您为答案传递的参数可能不会转换为字符串...首先将其转换为字符串,然后传递该字符串参数以获得正确答案..

for example..例如..

@Override
public void onClick(View v) {

// TODO Auto-generated method stub

    EditText edittext = (EditText) findViewById(R.id.edT);

    String str = edittext.getText().toString();

    int n = Integer.parseInt(str);

    int fact = n , i ,e;

    e = n;

    if (n==0)
    fact = 1;

    else

    for(i=0; i<n-1; i++)
        {
            fact = fact * (e - 1);
            e = e - 1;

        }


String str1 = String.valueOf(fact);       <-----//Your mistake maybe here.....

Toast.makeText(getApplicationContext(), str1, Toast.LENGTH_LONG).show();

                }

Whenever you find any Problem in Resource ID then Go To Project-->Clean每当您在资源 ID 中发现任何问题时,请转到项目--> 清理

And clean your project, R.java file will be generated Again.并清理您的项目,将再次生成R.java文件。

Do, fix project properties and clean the project.做,修复项目属性并清理项目。 Close eclipse and restart it again.关闭 eclipse 并重新启动它。 It will be resolved.它会得到解决。

Maybe I'm wrong but to me it looks as if you're importing only int not Strings with也许我错了,但在我看来,您似乎只导入了int而不是Strings

import static com.ankit.R.string.*;

And that could be the reason for your exception Resource not found String resource ID #...这可能是您的异常资源未找到字符串资源 ID #...

就我而言,我将 int 值转换为 string 值并解决了

String s = String.valueOf([int value]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM