Spinner activity not working
- by user1696863
I'm trying to create an activity, RateCardActivity, which has a spinner in it. My layout file for RateCardActivity is rate_card. My RateCardActivity looks like the following.
public class RateCardActivity {
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.rate_card);
Spinner spinner = (Spinner) findViewById(R.id.select_city);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.select_city, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
}
The layout file rate_card is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res/com.olacabs.customer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
android:gravity="center"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:text="@string/rate_card"
android:textColor="@color/white"
android:textSize="20dp"
custom:customFont="litera_bold.ttf" />
<Spinner
android:id="@+id/select_city"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
The RateCardActivity is called from another activity using an intent (I'm sure there is nothing wrong with that part of the code as when I substitute RateCardActivity with another activity, the application works fine). When I try to open the RateCardActivity in the application in emulator, the application crashes and I got the message "The application has stopped unexpectedly. Please try again later."
I can't seem to understand what I'm doing wrong, and want to know how to correct this?