我正在尝试在我的类中设置一个“SimpleCursorAdapter”对象变量,以便所有方法都可以访问它,所有这些都是非常标准的东西。目前,我的“OnCreate”方法中出现错误,显示以下错误:
错误:
cursorAdapter cannot be resolved to a type.
下面是类中声明的 SimpleCursorAdapter:
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) {
}
});
};