2017-05-06 28 views
0

使用此代码时出现错误。我一直在做一个文件管理器,每次我尝试运行应用程序时,它只是说“错误:文件名必须以.xml结尾”。就是这样,没有别的。我不知道发生了什么事,但如果有人能帮助我,那会很棒!“错误:文件名必须以.xml结尾”使用FileArrayAdapter

package com.recoded.fileexplorer; 

import java.util.List; 
import android.content.Context; 
import android.graphics.drawable.Drawable; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.ArrayAdapter; 
import android.widget.ImageView; 
import android.widget.TextView; 

public class FileArrayAdapter extends ArrayAdapter<Item>{ 

private Context c; 
private int id; 
private List<Item>items; 

public FileArrayAdapter(Context context, int textViewResourceId, 
         List<Item> objects) { 
    super(context, textViewResourceId, objects); 
    c = context; 
    id = textViewResourceId; 
    items = objects; 
} 
public Item getItem(int i) 
{ 
    return items.get(i); 
} 
@Override 
public View getView(int position, View convertView, ViewGroup parent) { 
    View v = convertView; 
    if (v == null) { 
     LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     v = vi.inflate(id, null); 
    } 

      /* create a new view of my layout and inflate it in the row */ 
    //convertView = (RelativeLayout) inflater.inflate(resource, null); 

    final Item o = items.get(position); 
    if (o != null) { 
     TextView t1 = (TextView) v.findViewById(R.id.TextView01); 
     TextView t2 = (TextView) v.findViewById(R.id.TextView02); 
     TextView t3 = (TextView) v.findViewById(R.id.TextViewDate); 
        /* Take the ImageView from layout and set the city's image */ 
     ImageView imageCity = (ImageView) v.findViewById(R.id.fd_Icon1); 
     String uri = "drawable/" + o.getImage(); 
     int imageResource = c.getResources().getIdentifier(uri, null, c.getPackageName()); 
     Drawable image = c.getResources().getDrawable(imageResource); 
     imageCity.setImageDrawable(image); 

     if(t1!=null) 
      t1.setText(o.getName()); 
     if(t2!=null) 
      t2.setText(o.getData()); 
     if(t3!=null) 
      t3.setText(o.getDate()); 
    } 
    return v; 
} 

}

+0

'我使用此代码时出现错误。你确定?那么究竟哪一条线?删除图像视图的所有代码,以便查找。 – greenapps

回答

0

请检查所有的绘制,菜单,颜色,ATTRS和布局,并确保任何非XML文件是存在的。如果是,那么将其删除并根据需要重新创建.xml文件

+0

不过,同样的错误... –

+0

清理和重建项目 –

相关问题