我想在我的應用程序中添加的ImageButton但是當我嘗試運行它,我得到這個錯誤:的ImageButton得到錯誤
03-21 14:57:41.936: E/AndroidRuntime(794): java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.facilit.target.app.android/br.com.facilit.target.app.android.LoginActivity}: android.view.InflateException: Binary XML file line #78: Error inflating class android.widget.ImageButton
我的XML代碼:
<ImageButton
android:id="@+id/btnEntrar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/txtFieldSenha"
android:layout_below="@+id/txtFieldSenha"
android:layout_marginTop="25dp"
android:background="@style/AppTheme"
android:contentDescription="@string/btn_entrar_desc"
android:src="@drawable/login_btn_entrar" />
Java代碼:
public class LoginActivity extends Activity {
ImageButton btnEntrar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_login);
addListenerOnButton();
}
private void addListenerOnButton() {
btnEntrar = (ImageButton) findViewById(R.id.btnEntrar);
final EditText email = (EditText) findViewById(R.id.txtFieldLogin);
final EditText token = (EditText) findViewById(R.id.txtFieldSenha);
btnEntrar.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.d(Constants.LOGIN_ACTIVITY, email.getText().toString().trim());
Log.d(Constants.LOGIN_ACTIVITY, token.getText().toString().trim());
}
});
}
清潔您的項目,然後再試一次。 – razielsarafan 2013-03-21 15:07:56