0

我无法让我的模拟器工作,它显示了菜单屏幕,但它没有通过屏幕显示“你的总数为 0”并添加按钮、减法按钮,我正在关注该教程:

http://www.youtube.com/watch?v=hUA_isgpTHI&list=EC2F07DBCDCC01493A

这是我的 avd 参数的屏幕:

  • avd名称:brixon
  • 设备:5.1 wvga(480x800:mdpi)
  • 目标:android 2.2 - API 级别 8
  • CPU/ABI:ARM(armeabi)
  • 键盘:勾选
  • 皮肤:检查
  • 前置摄像头:无
  • 后置摄像头:无
  • 内存选项:内存:512 虚拟机堆:16
  • 内部存储:200 Mib
  • SD卡:大小(无)

关于启动选项:

  • 皮肤:480x800
  • 密度:中等(160)
  • 将显示缩放到实际尺寸:未选中
  • 擦除用户数据:未选中
  • 从快照启动:选中
  • 保存到快照:选中

这是我的代码,我严格遵循教程:

package com.grolard.newboston;

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

public class MainActivity extends Activity {
    /** Called when the activity is first created. **/

    int counter;
    Button add, sub;
    TextView display;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        counter = 0;
        add = (Button) findViewById(R.id.bAdd);
        sub = (Button) findViewById(R.id.bSub);
        display = (TextView) findViewById(R.id.tvDisplay);
        add.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                counter++;
                display.setText("Your total is " + counter);
            }
        });
        sub.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                counter--;
                display.setText("Your total is " + counter);
            }
        });
    }
}

我做错了什么?

编辑:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.grolard.newboston"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="8" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.grolard.newboston.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
4

1 回答 1

0

If you have an Android device, connect it with usb cable and do the debug directly on the device. The emulator is slow and behaves in a strange way sometimes.

于 2013-05-18T22:02:07.843 回答