Java 分析活动期间出错
嗨,我创建了一个基于问答的应用程序,这个问题过去是基于图片的随机问题。编码中没有错误,应用程序已成功运行。它进入了主页,也进入了第二个主页,但当我转到问答部分时,图像被显示出来,不再对其进行进一步操作,我的代码的解析活动从这里开始,不再继续 当我在代码中放置一个try-catch块时,它在logcat中显示了我们Java 分析活动期间出错,java,android,Java,Android,嗨,我创建了一个基于问答的应用程序,这个问题过去是基于图片的随机问题。编码中没有错误,应用程序已成功运行。它进入了主页,也进入了第二个主页,但当我转到问答部分时,图像被显示出来,不再对其进行进一步操作,我的代码的解析活动从这里开始,不再继续 当我在代码中放置一个try-catch块时,它在logcat中显示了我们 02-17 14:49:20.582: ERROR/Parsing Pack(1194): Packthumb = butenemethylpropane 02-17 14:49:21
02-17 14:49:20.582: ERROR/Parsing Pack(1194): Packthumb = butenemethylpropane
02-17 14:49:21.502: ERROR/(1194): orientationvalue1 width = 320 Height = 480
02-17 14:49:21.502: ERROR/(1194): 2130837515
02-17 14:49:21.502: ERROR/(1194): butene_vs_2butene
02-17 14:49:21.532: ERROR/Timerview(1194): L= 20W= 15H= 200
02-17 14:49:21.562: ERROR/ParsingActivity oncreate(1194): ERROR = android.content.res.Resources$NotFoundException: Resource ID #0x0
下面是我对解析活动的编码
try
{
resID = getResources().getIdentifier(name, "raw", "com.menteon.speedimage0102");
saxparserfactory = SAXParserFactory.newInstance();
saxparser = saxparserfactory.newSAXParser();
xmlreader = saxparser.getXMLReader();
//getting the path of xml to parse
inputstream = this.getResources().openRawResource(resID);
xmlreader.setContentHandler(myXMLHandler);
//parsing the xml
xmlreader.parse(new InputSource(inputstream));
//getting the values of xml
item = myXMLHandler.getitem();
menteon = myXMLHandler.getmenteon();
polygon = myXMLHandler.getpolygon();
point = myXMLHandler.getpoint();
orientation = menteon.getOrientation();
o = menteon.getItem().size();
Log.e("ParsingActivity", "Orientation = "+orientation);
Log.e("ParsingActivity", "menteon size = "+o);
//calling function for random number
qnumber();
if(orientation.equalsIgnoreCase("portrait") && orientationvalue==2 )
{
alertportrait(orientation, orientationvalue);
}
else if(orientation.equalsIgnoreCase("landscape") && orientationvalue==1 )
{
alertlandscape(orientation, orientationvalue);
}
if(orientation.equalsIgnoreCase("portrait") && orientationvalue==1)
{
setRequestedOrientation(1);
alertstart();
}
else if(orientation.equalsIgnoreCase("landscape")&& orientationvalue==2)
{
setRequestedOrientation(2);
alertstart();
}
}
catch (Exception e)
{
e.printStackTrace();
Log.e("ParsingActivity oncreate", "ERROR = "+e);
}
}
请帮助我调试我的错误查看以下内容:
ERROR = android.content.res.Resources$NotFoundException: Resource ID #0x0
我怀疑您正在尝试查找id为“#0x0”的资源,但该资源不存在。可能您没有请求真实的ID。我看到以下代码与资源一起工作:
resID = getResources().getIdentifier(name, "raw", "com.menteon.speedimage0102");
inputstream = this.getResources().openRawResource(resID);
为了进行调试,我将记录resID,以检查第一行返回的内容。并检查这是否确实是正确的资源:我认为对getIdentifier的调用可能出错了?看看这个:
ERROR = android.content.res.Resources$NotFoundException: Resource ID #0x0
我怀疑您正在尝试查找id为“#0x0”的资源,但该资源不存在。可能您没有请求真实的ID。我看到以下代码与资源一起工作:
resID = getResources().getIdentifier(name, "raw", "com.menteon.speedimage0102");
inputstream = this.getResources().openRawResource(resID);
为了进行调试,我将记录resID,以检查第一行返回的内容。检查这是否确实是正确的资源:我认为对getIdentifier的调用可能出错了?错误来自该行
resID = getResources().getIdentifier(name, "raw", "com.menteon.speedimage0102");
这导致了异常
android.content.res.Resources$NotFoundException
当找不到请求的资源时,资源API会引发此异常。
请确保您拥有与指定名称相同的资源
希望这能对您有所帮助。错误来自线路
resID = getResources().getIdentifier(name, "raw", "com.menteon.speedimage0102");
这导致了异常
android.content.res.Resources$NotFoundException
当找不到请求的资源时,资源API会引发此异常。
请确保您拥有与指定名称相同的资源
希望这将对您有所帮助。方向也未检测到。方向也未检测到。