机器人:ID列表视图 [英] Android: id list view

查看:232
本文介绍了机器人:ID列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的XML声明的列表视图:

I have a list view declared in my xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" 
    android:background="#F7EFE8">

    <ListView android:id="@+id/android:list"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"/>
        <TextView android:id="@+id/android:empty"
          android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/no_message"/>
</LinearLayout>

但是,当我试图声明/用它去渣,未找到标识。但是,当我重​​新命名列表视图别的东西,并尝试使用它,我可以看到它R.id.的 _ 的,但是当R.id.list我找不到它。而且如果我不使用android:名单有一个错误,应该有一个列表视图id为机器人:名单。任何帮助吗?

But when I try to declare/use it to java, the id is not found. But when i rename the list view to something else and try to use it i can see it "R.id._" but when R.id.list I can't find it. And If I didn't use the android:list there's an error that there should be a list view whose id is android:list. Any help here?

推荐答案

您的ListView对象的id应该被指定为机器人:ID =@机器人:ID /列表

Your ListView object id should be specified either as android:id="@android:id/list"

ListView lv = (ListView) findViewById(android.R.id.list);

还是应该有一些其他的id例如机器人:ID =@ + ID / sampleList

ListView lv = (ListView) findViewById(R.id.sampleList);

检查: ListActivity

列表

希望这会有所帮助。

这篇关于机器人:ID列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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