Friday, 13 September 2013

Having a strange error when trying to implement a spinner in android

Having a strange error when trying to implement a spinner in android

I am trying to implement a spinner in android and while I was doing it I
got this strange syntax error and I am unable to resolve it.
The code I was writing :
package awad865.se206.contactmanager;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class AddContact extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_contact);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.add_contact, menu);
return true;
}
Spinner spinner = (Spinner) findViewById(R.id.contact_number_array);
//Create an ArrayAdapter using the string array and a default spinner
layout
ArrayAdapter<CharSequence> Adapter =
ArrayAdapter.createFromResource(this, R.array.phone_array,
android.R.layout.simple_spinner_item);
//Specify the layout to use when the list of choices appears
Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}
While I was writing "Adapter.setDropDownViewResource...." I get this weird
error and this is stack trace:
Multiple markers at this line
- Syntax error, insert "}" to complete ClassBody
- Syntax error, insert "enum Identifier" to complete
EnumHeaderName
- Syntax error on token "Adapter", delete this token
- Syntax error, insert "EnumBody" to complete EnumDeclaration
I can't figure what the problem is. Can someone please help?

No comments:

Post a Comment