Java setFilterQueryAdapter问题

Java setFilterQueryAdapter问题,java,android,Java,Android,可能重复: 我正在尝试为我的listview设置edittext筛选器 目前,我有以下代码,但在我的cursorAdapter对象的“setFilterQueryAdapter”上不断出现错误 我的“OnCreate方法”中有这段代码,其中一个错误是声称“void”的返回类型不正确,我认为它应该在OnCreate之外,但我不确定在哪里 希望有人能告诉我哪里出了问题。 代码如下: @Override protected void onCreate(Bundle savedInstance

可能重复:

我正在尝试为我的listview设置edittext筛选器

目前,我有以下代码,但在我的cursorAdapter对象的“setFilterQueryAdapter”上不断出现错误

我的“OnCreate方法”中有这段代码,其中一个错误是声称“void”的返回类型不正确,我认为它应该在OnCreate之外,但我不确定在哪里

希望有人能告诉我哪里出了问题。 代码如下:

    @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);




    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};






    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 onTextChanged(CharSequence s, int start, int before,
                int count) {


        }

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


        }

        @Override
        public void afterTextChanged(Editable s) {



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

        }


     });

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

             ********** ERROR **********
     cursorAdapter.setFilterQueryProvider(FilterQueryProvider()
    {
        public Cursor runQuery(CharSequence constraint)
        {
            changedAppoint.open();
            return changedAppoint.getChanges(constraint.toString());

        }
    });


    };

我自己设法解决了这个问题。这主要是因为我没有导入“FilterQueryProvider”