package com.nicotera.colton.londontransitguide;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class RoutesActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Spinner spinner = (Spinner) findViewById(R.id.route_name_spinner);
// Create an ArrayAdapter using the string array and a default
// spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.routes_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
);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
// TODO Auto-generated method stub
}
}
結果:
12-06 23:34:28.954: E/AndroidRuntime(765): Caused by: java.lang.NullPointerException
12-06 23:34:28.954: E/AndroidRuntime(765): at com.nicotera.colton.londontransitguide.RoutesActivity.onCreate(RoutesActivity.java:22)
問題は 22 行目にあるようですが、何が問題なのか正確にはわかりません。私はまったく新しい開発者なので、すべての助けに感謝します!