简体   繁体   English

扩展ListActivity android.R.id.list

[英]Extending ListActivity android.R.id.list

I am creating a Calculator. 我正在创建一个计算器。 When calculations are made, I need them displayed, then clickable so I can delete individual figures. 计算完成后,我需要显示它们,然后单击它,以便删除单个图形。 I followed this tutorial, and got this far. 我按照教程进行了讲解。 The only problem is when I run it, I get a FC and my logcat says this: 唯一的问题是,当我运行它时,我得到了一个FC,而我的logcat表示:

Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

All of my research say to change my id to android.R.id.list . 我所有的研究都说将我的ID更改为android.R.id.list I tried this, but still getting the same error. 我试过了,但仍然遇到相同的错误。

Here is my code: 这是我的代码:

CustomAdapter.java (extends ArrayAdapter) CustomAdapter.java (扩展ArrayAdapter)

private final Context context;
private final ArrayList<Calculations> items = null;
private final LayoutInflater inflater;
public CustomListAdapter(Context context, int textViewResourceId, ArrayList<Calculations>items){
    super(context, textViewResourceId, items);
    this.context = context;
    this.items = items;
    this.inflater = LayoutInflater.from(context);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final View v = convertView != null 
                       ? convertView
                       : infalter.inflate(R.layout.list_item, parent, false);

    final Calculations c = items.get(position);
    final TextView type = (TextView) v.findViewById(R.id.tvType);
    final TextView figure = (TextView) v.findViewById(R.id.tvFullFigure);
    final TextView amount = (TextView) v.findViewById(R.id.tvAmount);
    type.setText(c.getType());
    figure.setText(c.getFigure());
    amount.setText(c.getFigureAmount());

    return v;

}

acitivty_main.xml acitivty_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingTop="15dp"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:background="@drawable/concret_back"
    >

<!--Code remove for brevity-->

    <ListView
        android:id="@+id/android.R.id.list"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent" />

</RelativeLayout>

I have had this problem with another app I have done and never found a solution. 我用另一个我做过的应用程序遇到了这个问题,却从未找到解决方案。 So I though I would ask why do I keep getting the Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' error? 因此,尽管我会问为什么我一直保持原因Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'错误Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

Thanks for any input. 感谢您的任何投入。

Change your ListView id from 从更改您的ListView ID

     <ListView
        android:id="@+id/android.R.id.list"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent" />

to

     <ListView
        android:id="@android:id/list"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android ListActivity突然坏了,即使在那里,也找不到android.R.id.list - Android ListActivity suddenly broke, can't find android.R.id.list even though its there Android Listview质疑``android.R.id.list&#39;&#39; - Android Listview questioned 'android.R.id.list' Android android.R.id.list ListView Fragment异常 - Android android.R.id.list ListView Fragment Exception 在ListFragment中找不到ListView&#39;android.R.id.list&#39; - ListView 'android.R.id.list' is not found in ListFragment Android:内容必须有一个 id 属性为 &#39;android.R.id.list 的 ListView - Android: Content must have a ListView whose id attribute is 'android.R.id.list Logcat错误内容必须具有ID属性为&#39;android.R.id.list&#39;的ListView - Logcat error-Content must have a ListView whose id attribute is 'android.R.id.list' 您的内容必须具有ID属性为“ android.R.id.list”错误的ListView - Your content must have a ListView whose id attribute is 'android.R.id.list' error FATAL EXCEPTION:main java.lang.RuntimeException:Content具有id属性&#39;android.R.id.list&#39;的视图,它不是ListView类 - FATAL EXCEPTION: main java.lang.RuntimeException: Content has view with id attribute 'android.R.id.list' that is not a ListView class android:自己的类扩展活动和/或listactivity - android: own class extending activity and/or listactivity 有关扩展ListActivity的问题 - Problem regarding extending ListActivity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM