Reputation: 413
I am having the error:"Syntax error on tokens, delete these tokens"
Given below is the related file:
ReminderListActivity.java
package com.example.taskreminder;
import android.os.Bundle;
import android.app.ListActivity;
import android.view.Menu;
import android.widget.ArrayAdapter;
public class ReminderListActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reminder_list);
final String[] items;
items = new String[] {“Foo”,“Bar”,“Fizz”,“Bin”};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.reminder_row, R.id.text1, items);
setListAdapter(adapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_reminder_list, menu);
return true;
}
}
The error is on "items = new String[] {“Foo”,“Bar”,“Fizz”,“Bin”};" "Syntax error on tokens, delete these tokens"
Can some one help with this?
Upvotes: 0
Views: 147
Reputation: 785
Please remove double quotes from this line and give it again
items = new String[] {"Foo","Bar","Fizz","Bin"};
Upvotes: 3
Reputation: 16043
It's because you copy/pasted the code from the book. :)
Try manually to add the quotes. it should be double quotes like this: " ", not like this “ “
Upvotes: 1
Reputation: 6071
You've got some funky quotes in your code, more precisely the “
's and ”
's (instead of the plain "
's). This should do the trick:
items = new String[] {"Foo","Bar","Fizz","Bin"};
Upvotes: 1