Android 尝试使用自定义ArrayAdapter类将arrays.xml中的数组获取到ListView中。发生了什么?
谁能告诉我我做错了什么?Eclipse没有给我任何错误或警告,但在运行模拟器时没有填充我的ListView。非常感谢您的帮助。谢谢 这是onCreate中的内容: 这是我试图用作适配器的自定义内部类:Android 尝试使用自定义ArrayAdapter类将arrays.xml中的数组获取到ListView中。发生了什么?,android,listview,adapter,android-arrayadapter,Android,Listview,Adapter,Android Arrayadapter,谁能告诉我我做错了什么?Eclipse没有给我任何错误或警告,但在运行模拟器时没有填充我的ListView。非常感谢您的帮助。谢谢 这是onCreate中的内容: 这是我试图用作适配器的自定义内部类: 问题是下面这行 new MArrayAdapter(this, R.array.beds) 这与以下定义相对应 public ArrayAdapter (Context context, int textViewResourceId) 尝试从R.array.beds创建字符串元素列表,并使用以
问题是下面这行
new MArrayAdapter(this, R.array.beds)
这与以下定义相对应
public ArrayAdapter (Context context, int textViewResourceId)
尝试从R.array.beds创建字符串元素列表,并使用以下构造函数
public ArrayAdapter (Context context, int textViewResourceId, List<T> objects)
问题是下面这行
new MArrayAdapter(this, R.array.beds)
这与以下定义相对应
public ArrayAdapter (Context context, int textViewResourceId)
尝试从R.array.beds创建字符串元素列表,并使用以下构造函数
public ArrayAdapter (Context context, int textViewResourceId, List<T> objects)
首先尝试不使用这样的cusom布局,然后最终您可以使用自己的布局进行调整:
...
String[] bedsArray = getResources().getStringArray(R.array.beds);
bedList.setListAdapter(new ArrayAdapter<String>(
this,
android.R.layout.simple_expandable_list_item_1,
bedsArray));
...
首先尝试不使用这样的cusom布局,然后最终您可以使用自己的布局进行调整:
...
String[] bedsArray = getResources().getStringArray(R.array.beds);
bedList.setListAdapter(new ArrayAdapter<String>(
this,
android.R.layout.simple_expandable_list_item_1,
bedsArray));
...
请为您尝试加载的数组发布xml。您确定xml中没有错误吗?请为您尝试加载的数组发布xml。您确定xml中没有错误吗?我只需要使用您提到的getResources.getStringArray创建字符串数组。然后简单地将字符串[]添加到我的构造函数中,一切都很好!非常感谢。我只需要使用您提到的getResources.getStringArray创建字符串数组。然后简单地将字符串[]添加到我的构造函数中,一切都很好!非常感谢。