android 工作室找不到参数

android studio cannot find a parameter

我有一个使用 Firebase 的 Android 应用程序,但我遇到了查询错误。

在我的 class 文件中,我正在定义搜索并得到:

error: cannot find symbol variable query

这是我的 class 文件中的代码:

public class SearchFragment extends Fragment {

    private static final String TAG = "SearchFragment";
    private static final int NUM_GRID_COLUMNS = 3;
    private static final int GRID_ITEM_MARGIN = 5;

    //widgets
    private ImageView mSearchButton;
    private EditText mTitleET;
    private FrameLayout mFrameLayout;


    //vars
    private String mElasticSearchPassword;
    private String mPrefCity;
    private String mPrefStateProv;
    private String mPrefCountry;
    private ArrayList<Post> mPosts;
    private RecyclerView mRecyclerView;
    private PostListAdapter mAdapter;
    private String queryText;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        //View view = inflater.inflate(R.layout.fragment_search, container, false);
        View view = inflater.inflate(R.layout.fragment_search2, container, false);
        //mFilters = (ImageView) view.findViewById(R.id.ic_search);
        mSearchButton = (ImageView) view.findViewById(R.id.search_button);
        mTitleET = (EditText) view.findViewById(R.id.input_title);
        //mSearchText = (EditText) view.findViewById(R.id.input_search);
        mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
        mFrameLayout = (FrameLayout) view.findViewById(R.id.container);

        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        final DatabaseReference reference = FirebaseDatabase.getInstance().getReference();


        mSearchButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {


                Query query = reference.child("posts/").orderByChild("title").equalTo(mTitleET.getText().toString().trim()).
                        query.addListenerForSingleValueEvent(new ValueEventListener()
                {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot) {
                        if (dataSnapshot.exists()) {
                            // dataSnapshot is the "issue" node with all children with id 0
                            for (DataSnapshot ds : dataSnapshot.getChildren()) {
                                // do something with the individual "issues"
                                Log.i("TAG", ds.getValue().toString());
                            }
                        }
                    }

                    @Override
                    public void onCancelled(DatabaseError databaseError) {
                        Log.i("ERRRRRROORRR", databaseError.getMessage() + ", so....let´s take a coffee");

                    }
                });

            }
        });    
    }

    private void setupPostsList(){
        RecyclerViewMargin itemDecorator = new RecyclerViewMargin(GRID_ITEM_MARGIN, NUM_GRID_COLUMNS);
        mRecyclerView.addItemDecoration(itemDecorator);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), NUM_GRID_COLUMNS);
        mRecyclerView.setLayoutManager(gridLayoutManager);
        mAdapter = new PostListAdapter(getActivity(), mPosts);
        mRecyclerView.setAdapter(mAdapter);
    }


}

问题似乎出在以下几行(见附图): 是什么导致了这个错误,这个错误的解决方案是什么?

trim() 调用

后,你有一个多余的点 (.)
Query query = reference.child("posts/").orderByChild("title").equalTo(mTitleET.getText().toString().trim()). // <- this one

这显然是一个错字。