2011-02-22 35 views
0

我会通过教程HelloFormStuff位于hereAndroid的教程 - HelloFormStuff - 无法解决绘制错误

我停留在第一个迷你型的教程此页面被简单地添加使用图像的按钮向右作为不同的状态,点击时显示敬酒信息。

我在main.xml中的布局文件收到此错误:

错误!无法解析绘制 “C:\ Documents和Settings \雷 詹姆斯\工作区\ HelloFormStuff \水库\绘制\ android_button.xml” 属性中的“背景”异常 细节窗口记录>显示 视图>错误日志

我已保存在res /可绘制文件夹以下图象:

android_normal.png android_focused.png android_pressed.png

这里是码f或者被保存在res /抽拉/ android_button.xml按钮的不同的状态:

<?xml version="1.0" encoding="utf-8"?> 
<Selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@drawable/android_pressed" 
      android:state_pressed="true" /> 
    <item android:drawable="@drawable/android_focused" 
      android:state_focused="true" /> 
    <item android:drawable="@drawable/android_normal" /> 
</Selector> 

这里是main.xml中的代码:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 
    <Button 
     android:id="@+id/button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="10dp" 
     android:background="@drawable/android_button" /> 
</LinearLayout> 

下面是HelloFormStuff活性类的代码:

package com.example.HelloFormStuff; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.Toast; 

public class HelloFormStuff extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     final Button button = (Button)findViewById(R.id.button); 
     button.setOnClickListener(new OnClickListener() { 
      public void onClick(View v) { 
       // Perform action on clicks 
       Toast.makeText(HelloFormStuff.this, "Beep Bop", Toast.LENGTH_SHORT).show(); 
      } 
     }); 
    } 
} 

我没有其他的错误出现在日食中。任何帮助将不胜感激。

项目属性: 目标:Android 1.5的API 3 编辑:Eclipse版本:3.6.1

任何帮助将不胜感激。谢谢。

回答

1

也许是因为你大写“选择器”?

+0

是的,谢谢一堆。我现在觉得自己很笨,但是谢谢你的帮忙。它现在有效。谢谢。 – RayJamesFun 2011-02-22 19:24:06

相关问题