错误:匿名类不是抽象的,不会覆盖抽象方法

时间:2015-12-31 10:03:19

标签: java android android-activity android-studio listactivity

请问,每当我尝试构建我的android项目时,我在下面的方法中都会出错。

方法:

query.findInBackground(new FindCallback() {
            @Override
            public void done(List<ParseObject> objects, ParseException e) {
                mProgressBar.setVisibility(View.INVISIBLE);

                if (e == null) {
                    objects = removeCurrentUser(objects);
                    mUsers = objects.toArray(new ParseObject[0]);

                    // Get user relations
                    ParseRelation userRelations = ParseUser.getCurrentUser().getRelation("UserRelation");
                    userRelations.getQuery().findInBackground(new FindCallback() {
                        @Override
                        public void done(List<ParseObject> results, ParseException e) {
                            if (e == null) {
                                UsersAdapter adapter = new UsersAdapter(SelectUsersActivity.this, mUsers, new ArrayList<ParseObject>(results));
                                setListAdapter(adapter);
                            }
                            else {
                                Log.e(TAG, "Exception caught!", e);
                            }
                        }
                    });
                }
                else {
                    // Something went wrong.
                    Toast.makeText(SelectUsersActivity.this, "Sorry, there was an error getting users!", Toast.LENGTH_LONG).show();
                }
            }
        }//
         );

错误:

  

错误:(46,45)错误:不是抽象而不是   覆盖FindCallback中的抽象方法done(List,ParseException)

     

错误:(48,16)错误:名称冲突:   在和中完成(List,ParseException)   FindCallback中的done(List,ParseException)具有相同的擦除,   但是,当T是一个类型变量时,它们都不会覆盖另一个:T扩展   在接口FindCallback

中声明的ParseObject

这是Screenshot

1 个答案:

答案 0 :(得分:2)

您尚未对您的匿名FindCallback子类进行参数化,因此您的done签名与FindCallback#done签名不匹配,因为done签名非参数化版本为done(List<Object>results, ParseException e)

要修复它,请对其进行参数化:

userRelations.getQuery().findInBackground(new FindCallback<ParseObject>() {
// Add ---------------------------------------------------^^^^^^^^^^^^^