2

I am trying to set a 'SimpleCursorAdapter' object variable within my class so that all of the methods can access it, all very standard stuff. At the moment I'm getting an error within my 'OnCreate' method showing the following error:

Error:

cursorAdapter cannot be resolved to a type.

Heres the declared SimpleCursorAdapter within the class:

package com.example.flybase2;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.widget.SimpleCursorAdapter;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;

public class ViewAppointments extends ListActivity implements OnClickListener {
SimpleCursorAdapter cursorAdapter;
ListView searchedAppView;
ImageButton searchAppoints;
EditText searchAppName;
Long id;



DBHandlerApp delApp = new DBHandlerApp(this, null, null);

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    setContentView(R.layout.appointmentview);

    searchedAppView = (ListView)findViewById(android.R.id.list);

    searchAppoints = (ImageButton) findViewById(R.id.btnSearchAppointName); 
    searchAppName = (EditText) findViewById(R.id.inputAppointName); 

    DBHandlerApp DBAppointments = new DBHandlerApp(this, null, null);

    DBHandlerApp searchApps = new DBHandlerApp(this, null, null);

    searchApps.open();


    Cursor cursor = searchApps.getAppointmentsData();
    searchApps.close();
    startManagingCursor(cursor);



    @SuppressWarnings("static-access")
    String [] from = new String [] {DBAppointments.KEY_NAMEAPP, DBAppointments.KEY_TYPEAPP, DBAppointments.KEY_TIMEAPP, DBAppointments.KEY_DATEAPP, DBAppointments.KEY_COMMENTAPP};
    int [] to = new int [] {R.id.txtAppointName, R.id.txtAppointType, R.id.txtAppointTime, R.id.txtAppointDate, R.id.txtAppointCom};

    @SuppressWarnings("deprecation")


    //ERROR: cursorAdapter cannot be resolved.
    cursorAdapter = new SimpleCursorAdapter(this, R.layout.setappointviews, cursor, from, to);
    searchedAppView.setAdapter(cursorAdapter);

    searchedAppView.setTextFilterEnabled(true);

    searchAppoints.setOnClickListener(this);



    searchAppName.addTextChangedListener(new TextWatcher()
     {

        @Override
        public void afterTextChanged(Editable s) {

            cursorAdapter.getFilter().filter(s.toString());


        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {


        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before,
                int count) {

        }

     });

    };
4

2 に答える 2

0

あなたの問題は、注釈の場所にありました。

@SuppressWarnings("deprecation")

内部onCreate()にあり、(奇妙なことに)エラーが発生します。

于 2013-02-03T20:25:04.620 に答える
0

そのオブジェクトは必要ありません。できるよ:

searchedAppView.getAdapter(); //listView.getAdapter()

アクティビティの好きな場所に。

于 2013-02-03T19:59:51.077 に答える