android无法解析PNG文件
问题描述:
我开发了一款在模拟器上运行完美的应用程序,但是当我尝试在手机上运行它时,应用程序错误地指出java.io.FileNotException:res/drawable/divider_horizontal_dark.9 .pngandroid无法解析PNG文件
我以为应用程序丢失了这个文件(可能是android系统文件),所以我在网上的其他地方发现了这个文件,并将其放在drawable下但是徒劳。该应用程序仍然错误与以前相同的错误。
任何想法这里的问题是什么?
xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:gravity="left|center"
android:layout_width="wrap_content" android:paddingBottom="5px"
android:paddingTop="5px" android:paddingLeft="5px" >
<ImageView android:id="@+id/linkImage" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_marginRight="6dip"
android:src="@drawable/icon" />
<LinearLayout android:orientation="vertical"
android:layout_width="0dip" android:layout_weight="1"
android:layout_height="fill_parent">
<TextView android:id="@+id/firstLineView"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:textColor="#FFFF00" android:text="first line title"></TextView>
<TextView android:id="@+id/secondLineView"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="second line title" android:layout_marginLeft="10px" android:gravity="center"
android:textColor="#0099CC"></TextView>
</LinearLayout>
</LinearLayout>
和代码的一部分,其中的应用程序崩溃时加载..你可以看到,有没有在那里我有使用的文件divider_horizontal_dark.9.png
public View getView(int position, View convertView, ViewGroup parent){
ViewHolder holder;
if(convertView == null){
convertView = mInflater.inflate(R.layout.listview,null);
holder = new ViewHolder();
holder.firstLine = (TextView) convertView.findViewById(R.id.firstLineView);
holder.secondLine = (TextView) convertView.findViewById(R.id.secondLineView);
holder.imageView = (ImageView) convertView.findViewById(R.id.linkImage);
//holder.checkbox = (CheckBox) convertView.findViewById(R.id.star);
holder.firstLine.setFocusable(false);
holder.secondLine.setFocusable(false);
holder.imageView.setFocusable(false);
//holder.checkbox.setFocusable(false);
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
.....
好像他们已经解决了该问题 http://code.google.com/p/transdroid/issues/detail?id=14
但我有点不明白它
答
您需要为资源使用一个id,而不是尝试通过提供路径(在源代码中)来打开该文件。有大量的Android文档的解释如何做到这一点...
http://developer.android.com/guide/topics/resources/providing-resources.html
http://developer.android.com/guide/topics/resources/accessing-resources.html
你是如何试图打开它。我们应该如何帮助而不发布一些代码。 – Falmarri 2010-12-10 00:18:16
我很抱歉,但我应该发布什么代码部分...因为我不是在任何地方调用该文件,你可以告诉我哪部分代码你要我发帖 – 2010-12-10 14:48:21