Android的没有的ListView适配器RESOURCEID [英] Android there is no ListView adapter resourceId

查看:191
本文介绍了Android的没有的ListView适配器RESOURCEID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于Android中的Hello-的ListView turorial,的http://开发商.android.com /资源/教程/视图/ HELLO-listview.html

based on Hello-ListView turorial in Android, http://developer.android.com/resources/tutorials/views/hello-listview.html

setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES));

有一个错误,因为没有R.layout.list_item

had an error because there is no R.layout.list_item

previously我曾跟随本教程中,创建于RES /布局文件夹中的文件list_item.xml

previously i had followed the tutorial, created the file list_item.xml on the res/layout folder

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp">
</TextView>

它不具有不同的名称既不工作(main_list_view.xml)

it doesnt work with different name neither (main_list_view.xml)

这是完整的源

String[] appList;

ListView mainLv;    

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main); 
    appList = this.getResources().getStringArray(R.array.for_main_layout);
    mainLv = (ListView)findViewById(R.id.ListView01); 
    mainLv.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, appList)); //<<
}

更新!
阿其作品现在创建新项目的时候!当我在第一个项目中使用文件>新建> Android的XML文件,它不工作,但现在在不同的项目中,我使用文件>新建>文件,也许这是一个可能的错误?

Updated! Ah its works now when creating new project! When i use File>new>Android XML File in the first project, it doesnt work, but now in different project, i use file>new>File, maybe is this a possible bug?

推荐答案

您可能已经使用了Android提供的布局:

You could have used the android supplied layout:

android.R.layout.simple_list_item_1

试试那个。

这篇关于Android的没有的ListView适配器RESOURCEID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆