java:54: error: class, interface, or enum expected and Build failed with an exception

i want to build a photoplayer. I have 2 file, one is xml file which have 2 buttons and 1 image view, another one is the java class to run the program so that can see the preious and next photo in image view. However, there are 2 error that i cant run the program and i dont know why.

The second one package com.fyp.user.myapplication;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;

/**
 * Created by User on 2/12/2015.
 */
public class photoplayer extends MainActivity {

    int[] imgID = {R.drawable.apple};
    private Button btnPrev, btnNext;
    private ImageView imgPhoto;
    int p = 0;
    int count = imgID.length;

    @Override
    protected void onCreate(Bundle savedInstancestate) {
        super.onCreate(savedInstancestate);
        setContentView(R.layout.numberplayer);
        btnPrev = (Button) findViewById(R.id.btnprev);
        btnNext = (Button) findViewById(R.id.btnnext);
        imgPhoto = (ImageView) findViewById(R.id.imgPlayer);


        btnPrev.setOnClickListener(btnPrevListerner);
        btnNext.setOnClickListener(btnNextListerner);
    }

        private Button.OnClickListener btnPrevListerner = new Button.OnClickListener() {
            public void onClick(View v) {
                p--;
                if (p < 0)
                    p = count - 1;
                imgPhoto.setImageResource(imgID[p]);
                setTitle("Num" + (p + 1) + "/" + count);

            }
        };
        private Button.OnClickListener btnNextListerner = new Button.OnClickListener() {
            public void onClick(View v) {
                p++;
                if (p == count)
                    p = 0;
                imgPhoto.setImageResource(imgID[p]);
                setTitle("Num" + (p + 1) + "/" + count);

            }
        };
    }
}

The first one

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Previous"
        android:id="@+id/btnprev" />

    <ImageView
        android:layout_width="81dp"
        android:layout_height="140dp"
        android:id="@+id/imgPlayer"
        android:scaleType="fitCenter"
        android:layout_gravity="center_vertical"
        android:src="@drawable/apple" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="next"
        android:id="@+id/btnnext" />
</LinearLayout>

Answers


java:54: error: class, interface, or enum expected with an exception

There is an extra closing curly bracket } in your code.Remove the last closing curly bracket and you will be good.


Need Your Help

php header not forwarding ie9

php

I use the following which works perfectly in all browsers, except ie9