我正在我的 Android 应用程序中开发带有图像和文本视图的自定义列表视图,但是,我完全按照此链接中的教程进行操作:http: //theopentutorials.com/tutorials/android/listview/android-custom-listview-with -image-and-text-using-baseadapter/#Project_Folder_Structure 。在引用放置在可绘制文件中的图像时,我在 ListActivity 类中遇到了一个问题,这是我的代码:package com.Android.mysmartrecipeassistant;
import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
public class BookListActivity extends Activity implements OnItemClickListener
{
public static final String[] recTitles = new String[] { "Cheese Salad",
"Burger and Fries", "Chicken", "Sandwiches", "Potato Sauce" };
public static final Integer[] recImgs = new Integer[] {R.drawable.recipe, R.drawable.salad};
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
}
}
我的问题在于以下行:
public static final Integer[] recImgs = new Integer[] {R.drawable.recipe, R.drawable.salad};
尽管我将图像放置在可绘制对象中,但我的代码看不到这些图像并指示错误(图像无法解析或不是字段)
无论如何,我还没有完成这个类的代码。你能帮我解决这个问题吗?