Android Studio Cannot Find A Parameter

I have an Android app that uses Firebase and I am having an error with a query.

In my class file I am defining the search and I am getting:

error: cannot find symbol variable query

Here is the code from my class file:

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;

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

    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;

    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(;
        mSearchButton = (ImageView) view.findViewById(;
        mTitleET = (EditText) view.findViewById(;
        //mSearchText = (EditText) view.findViewById(;
        mRecyclerView = (RecyclerView) view.findViewById(;
        mFrameLayout = (FrameLayout) view.findViewById(;

        return view;

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

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

                Query query = reference.child("posts/").orderByChild("title").equalTo(mTitleET.getText().toString().trim()).
                        query.addListenerForSingleValueEvent(new ValueEventListener()
                    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());

                    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);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), NUM_GRID_COLUMNS);
        mAdapter = new PostListAdapter(getActivity(), mPosts);


It is specifically the following line(s) that appear to be the problem (see attached pic): enter image description here What is causing this error and what is the solution for this error?



You have a redundant dot (.) after the trim() call at

Query query = reference.child("posts/").orderByChild("title").equalTo(mTitleET.getText().toString().trim()). // <- this one

which is apparently a typo.