-1

I am developing a piano app, currently I am working on something to make my buttons play their sounds while user "slides" his finger over them.

To achieve this, I've chosen onFocusChangeListener. It is not the part, in which i am adding sounds into, but right now i am to make buttons work as an example.
Unfortuntely, I have got a couple of errors.

JAVA:

package com.example.android.appname;

import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ImageView button = (ImageView) findViewById(R.id.button);
    button.setOnFocusChangeListener()**setOnFocusChangeListener (OnfocusChangeListener) in View cannot be applied to ()**;**'}'expected** 

   public void onFocusChange**methed 'OnFocusChange(android.view.View,boolean)' is never used**(View v, boolean hasFocus))**"{" or ";" expected|unexpected token**  {
        if(hasFocus**cannot resolve symbol "hasFocus"**){
            Toast.makeText(getApplicationContext(), "FOCUS", Toast.LENGTH_LONG).show();
        }else {
            Toast.makeText(getApplicationContext(), "NO FOCUS", Toast.LENGTH_LONG).show();
        }
   }

}); **class or interface expected**
}**class or interface expected**

Errors are shown with in **'s

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Old York
  • 73
  • 1
  • 9

1 Answers1

0

You're missing a } at the end of the file ...

Missing one of those will give you that error. Next time maybe try to solve it yourself?

Ali Bdeir
  • 4,151
  • 10
  • 57
  • 117