2013-06-21 135 views
0

我试图把下面的列表视图的线性布局XML出于某种原因,我得到这个错误上述列表视图线性布局

android.widget.ImageButton不能转换到android.widget.ListView

at com.yonivy。 ... ... .onCreate的.java:37

这里的XML

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

<ListView 
    android:id="@+id/mList" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:divider="@android:color/transparent" 
    android:dividerHeight="1.0sp" 
    android:padding="10dp" > 
</ListView> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="10dp" 
    android:divider="?android:attr/dividerVertical" 
    android:orientation="horizontal" 
    android:showDividers="middle" > 

    <ImageButton 
     android:id="@+id/addBtn" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="@android:color/transparent" 
     android:src="@drawable/content_new" /> 

    <ImageButton 
     android:id="@+id/editBtn" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="@android:color/transparent" 
     android:src="@drawable/content_edit" /> 

    <ImageButton 
     android:id="@+id/deleteBtn" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="@android:color/transparent" 
     android:src="@drawable/navigation_cancel" /> 
</LinearLayout> 

而这里的的onCreate

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.category_activities); 

    lv = (ListView) findViewById(R.id.mList); // line 37 

    // ... 

} 

如果我把列表视图作为最后孩子一切工作正常,但这不是我想要的。

+0

安置自己的完整的Java代码 –

+0

项目 - >清洁......... – 10s

+0

如果你想从开始您的APK它发生,例如eclipse没有保存更改.... – Opiatefuchs

回答

0

我以前也有这个 - 尝试清洗和重建

+0

那是愚蠢的......谢谢。 –