此行中的多个标记 - 无法解析Id或不是字段 - button1无法解析或不是字段

时间:2014-03-23 20:08:04

标签: java android button

我在" R.Id.button1"说" - Id无法解析或不是字段 - button1无法解析或不是字段。"

package com.example.chopbuilderfordrums;

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

public class ExerciseList extends Activity implements View.OnClickListener {

        Button button1;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_exercise_list);
        button1 = (Button)findViewById(R.Id.button1);
        button1.setOnClickListener(this);
    }

    private void button1Click()
    {
        startActivity(new Intent("com.example.chopbuilderfordrums.LaunchWarmupsList"         ));    
    }

    public void onClick (View v) {
        switch (v.getId())
        {
        case R.Id.button1:
            button1Click();
            break;
        }
    }



}

我的主要活动布局:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/textview_exercises"
        android:layout_gravity="center"
        android:gravity="center_horizontal"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/button_warmups" />

    <Button
        android:id="@+id/button2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/button_endurance" />

    <Button
        android:id="@+id/button3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/button_speed" />

    <Button
        android:id="@+id/button4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/button_rudiments" />

    <Button
        android:id="@+id/button5"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/button_singlestrokeroll" />


</LinearLayout>

我的Android Manifest:

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

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

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

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="LaunchWarmupsList"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.example.chopbuilderfordrums.LaunchWarmupsList"     />

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

</manifest>

请帮帮我!!我很新!!并且,似乎这是阻止我从按钮1启动另一个活动的唯一错误

0 个答案:

没有答案