按钮无法解析为类型 - Android开发

use*_*817 2 java xml eclipse debugging android

我是android开发的新手,我有一些调试问题.我正在从一个名为"TheNewBoston"的youtube频道学习并在第10课遇到问题.我没有使用与教程中的人相同的src包,因为我找不到它所以我想知道这是否导致了这个问题.

添加和子按钮都具有相同的'此行上的多个标记 - 按钮无法通过OnCreate方法中的类型'错误来解析.

Java的:

package com.example.thenewboston.sam;

import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.example.thenewboston.sam.util.SystemUiHider;
public class FullscreenActivity extends Activity {
/**
 * Whether or not the system UI should be auto-hidden after
 * {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
 */

int counter;
Button add, sub;
TextView Display;
private static final boolean AUTO_HIDE = true;
/**
 * If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
 * user interaction before hiding the system UI.
 */
private static final int AUTO_HIDE_DELAY_MILLIS = 3000;

/**
 * If set, will toggle the system UI visibility upon interaction. Otherwise,
 * will show the system UI visibility upon interaction.
 */
private static final boolean TOGGLE_ON_CLICK = true;

/**
 * The flags to pass to {@link SystemUiHider#getInstance}.
 */
private static final int HIDER_FLAGS = SystemUiHider.FLAG_HIDE_NAVIGATION;

/**
 * The instance of the {@link SystemUiHider} for this activity.
 */
private SystemUiHider mSystemUiHider;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fullscreen);
    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--;
        }
    });

    final View controlsView = findViewById(R.id.fullscreen_content_controls);
    final View contentView = findViewById(R.id.fullscreen_content);

    // Set up an instance of SystemUiHider to control the system UI for
    // this activity.
    mSystemUiHider = SystemUiHider.getInstance(this, contentView,
            HIDER_FLAGS);
    mSystemUiHider.setup();
    mSystemUiHider
        .setOnVisibilityChangeListener(new               SystemUiHider.OnVisibilityChangeListener() {
                // Cached values.
                int mControlsHeight;
                int mShortAnimTime;
Run Code Online (Sandbox Code Playgroud)

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"

    >

    <!--
     The primary full-screen view. This can be replaced with whatever view
     is needed to present your content, e.g. VideoView, SurfaceView,
     TextureView, etc.
    -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Your total is 0"
android:textSize="45sp"
android:textStyle="bold"
android:layout_gravity="center"
android:gravity="center"
android:id="@+id/tvDisplay"


      />

  <Button
    android:layout_width="250sp"
    android:layout_height="wrap_content"
    android:text="Add one" 
    android:layout_gravity="center"
    android:textSize="20sp"
    android:id="@+id/bAdd"
    ></Button>
  <Button
    android:layout_width="250sp"
    android:layout_height="wrap_content"
    android:text="Subtract one" 
    android:layout_gravity="center"
    android:textSize="20sp"
    android:id="@+id/bSub"
    ></Button>

       </LinearLayout>
       <!--
       This FrameLayout insets its children based on system windows using
       android:fitsSystemWindows.
       -->  
Run Code Online (Sandbox Code Playgroud)

Bla*_*elt 5

add.SetOnClickListener
Run Code Online (Sandbox Code Playgroud)

sSetOnClickListener的必须是小写.

演员阵容:

(button)
Run Code Online (Sandbox Code Playgroud)

如评论框中所述,这是错误的.它应该是Button