r00
r00

Reputation: 35

Where am I missing a { or } in this small section of Android code?

I seem to be having a problem with a syntax error within Eclipse while doing one of the tutorials from the Android for Dummies book. It's probably something simple, but I keep looking at the code and it seems right to me.. Here's a screenshot. Ah, I can't post images as I'm a new user. Here are the jpg links instead.

https://i.sstatic.net/1DWzj.jpg

I can't figure out why Eclipse is giving me those three lines as an error. When I hover over it, it says that I'm missing a } or maybe I have too many, but I think I've accounted for all of them! When I remove those four lines starting with the second @Override, everything parse out correctly. Here it is without those lines.

https://i.sstatic.net/GcSHI.jpg

Upvotes: 1

Views: 86

Answers (2)

Edwin Buck
Edwin Buck

Reputation: 70909

It's a clever typo, but if you look very closely.

protected void onListItemClick(ListItem 1, ...

has it's first parameter as a ListItem, but it has a variable name as the numeral 1, not the letter l. Since a variable name isn't allowed to start with a digit, the parameter list is not valid, so the method declaration is not valid, and hence the block under it is not properly opened.

It's obvious you meant the letter l as it is used within the block.

Upvotes: 4

Jaydeep Khamar
Jaydeep Khamar

Reputation: 5985

You are using 1 as a variable name in this method

protected void onListItemClick(ListView 1, View v, int position, long id){}

I think this is the cause of ur error. Check it

Upvotes: 1

Related Questions