Booking.java
package one.two;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.SimpleCursorAdapter;
import android.widget.Spinner;
public class Booking extends Activity
{
private DBAdapter db;
private Spinner colourSpinner;
private String txtArrival;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
db = new DBAdapter(this);
db.open();
setContentView(R.layout.booking);
Cursor c = db.getSpinnerData();
startManagingCursor(c);
String[] from = new String[]{DBAdapter.KEY_ARRIVAL};
int[] to = new int[]{R.id.txtArrival};
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c, from, to );
adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
Spinner colourSpinner = (Spinner) findViewById(R.id.myspinner);
colourSpinner.setAdapter(adapter);
}
我将在哪里声明我的{KEY_ARRIVAL},因为我已经在我的DBAdapter.java中声明了我的KEY_ARRIVAL。但是有一个错误表明KEY_ARRIVAL无法解决?
答案 0 :(得分:0)
你是说你在DBAdapter中定义了一个字符串KEY_ARRIVAL
?设为public static final
,您可以通过DBAdapter.KEY_ARRIVAL
访问它。