开发者

Error with taking spinner data from database

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; 
开发者_Go百科    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);
        }

Where would i declare my {KEY_ARRIVAL} as i already have my KEY_ARRIVAL declared in my DBAdapter.java. But there is an error stating KEY_ARRIVAL cannot be resolved?


Are you saying you have a string KEY_ARRIVAL defined in DBAdapter? Make it public static final, and you can access it via DBAdapter.KEY_ARRIVAL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜