Novice Help - Syntax Error

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Novice Help - Syntax Error

Postby justin.ferrell.92 » Wed May 26, 2010 5:18 am

I realize this is a question that probably has a really easy solution, but I'm receiving a syntax error when trying to run my code. The error is supposably in the last semicolon.

Here is the code:

package com.example.sudoku;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.View.OnTouchListener;


public class Sudoku extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public OnTouchListener mCorkyListener = new OnTouchListener() {
public void onTouch(View sudoku);
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);{
v.vibrate( 300);

}
}


Note: This isn't a Sudoku app, that is just the name we gave it for the time being.
justin.ferrell.92
Once Poster
Once Poster
 
Posts: 1
Joined: Wed May 26, 2010 4:12 am

Top

Re: Novice Help - Syntax Error

Postby vengeance_mj » Sat May 29, 2010 6:24 am

Code: Select all
public OnTouchListener mCorkyListener = new OnTouchListener() {
public void onTouch(View sudoku);
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);{
v.vibrate( 300);

}



onTouch is a method and so there should not be a ; after it Also remove the opening brace after (Context.VIBRATOR_SERVICE);

Replace the above code by this
Code: Select all
public OnTouchListener mCorkyListener = new OnTouchListener() {
public void onTouch(View sudoku)
{
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate( 300);
  }
};
vengeance_mj
Senior Developer
Senior Developer
 
Posts: 174
Joined: Thu Oct 29, 2009 2:32 am

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 2 guests