2

I'm trying to learn Java through a tutorial on Aide and have entered what I believed was the correct code:

package com.aide.trainer.myapp; import android.app.*; import android.os.*; import android.view.*; import android.view.View.*; import android.widget.*; public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set main.xml as user interface layout setContentView(R.layout.main); final TextView textView = (TextView) findViewById(R.id.mainTextView1); Button button = (Button) findViewById(R.id.mainButton1); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View p1) { // TODO: Implement this method TextView textView = (TextView) findViewById(R.id.mainTextView1); textView.setText("Clicked"); } }); button.setOnLongClickListener(new OnLongClickListener() { @Override public void onLongClick(View p1) { } }); } } 

But at public void onLongClick(View p1), there is an error around void that says:

The type of this method is incompatible with the type of the overridden method 'android.view.View.OnLongClickListener.onLongClick(android.view.View)'

I can't figure out what I did wrong. Does anyone know?

0

1 Answer 1

5

In an OnLongClickListener, onLongClick(…) must return boolean, not void.

Sign up to request clarification or add additional context in comments.

1 Comment

Nailed it, I owe you my sanity

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.