在我的项目中,我使用了一个名为PigeonSketch的活动,每当我打开该活动时,它都会提供android.view.InflateException: Binary XML file line #15: Error inflating class <unknown>
下面是我的Activity类和XML布局文件
public class PigeonSketch extends Activity {
private RelativeLayout dashBoard;
private ImageView imagePigeon;
private Button search;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pigeon_sketch);
setTitle("Pigeon")
dashBoard = (RelativeLayout) findViewById(R.id.pigeon_dashBoard);
imagePigeon = (ImageView) findViewById(R.id.pigeonsketch);
search = (Button) findViewById(R.id.searchButton)
}和布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".GridViewList" >
<RelativeLayout
android:id="@+id/pigeon_dashBoard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<ImageView
android:id="@+id/pigeonsketch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:src="@drawable/image_pigeon"
android:visibility="invisible" />
</RelativeLayout>
<Button
android:id="@+id/searchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Search" />
</RelativeLayout>我该如何解决这个问题?
发布于 2014-11-22 15:16:38
试着改变
tools:context=".GridViewList"到这个
tools:context=".PigeonSketch"或删除行..
发布于 2014-11-22 15:18:52
首先,您使用了错误的工具引用:
tools:context=".PigeonSketch"其次,在xml中定义按钮,并使用ImageButton查找,因此在Activity中将ImageButton替换为按钮:
private Button search;
search = (Button) findViewById(R.id.searchButton)https://stackoverflow.com/questions/27075026
复制相似问题