(error: class, interface, or enum expected) this error showed up 15 times

336 views Asked by At

This is the code of the TopSectionFragment I made watching the newboston series

package com.example.rohanmarwaha.memecreator;

import android.os.Bundle;
import android.app.Fragment;
import android.support.annotation.Nullable;
import android.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.app.Activity;
import android.widget.Button;
import android.widget.EditText;
import java.util.zip.Inflater;

public class TopSectionFragment extends Fragment {

    private static EditText toptextinput;
    private static EditText bottomtextinput;

    TopSectionListener activitycommander;

    public interface TopSectionListener {
        public void creatememe(String top, String bottom);
    }
}@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    try {
        activitycommander = (TopSectionListener) activity
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString());
    }

}



@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstancestate) {
    View view = Inflater.inflate(R.layout.top_fragment, container, false);

    toptextinput = (EditText) veiw.FindViewById(R.id.bottomfragment);
    bottomtextinput = (EditText) view.FindViewById(R.id.bottomtextinput);
    final button = (Button) view.FindViewById(R.id.button);

    button.setOnClickListener(
    new View.OnClickListener() {
        public void onClick(View v) {

            buttonClicked(v);
        }
    });

    return view;

    public void buttonClicked(View view) {
        actioncommander.creatememe(toptextinput.getText().toString(), bottomtextinput.getText().toString())
    }

}

I have got (error: class, interface, or enum expected) error 15 times. I am quite new with the android application development.Please help!!

1

There are 1 answers

0
Chris Stillwell On

You closed your class before your methods.

Simply change this line

}@Override
public void onAttach(Activity activity) {

To this

@Override
public void onAttach(Activity activity) {