Android Firebase cannot resolve method getRef(position)

前端 未结 1 544
执念已碎
执念已碎 2021-01-28 12:36

I see there are a lot of examples in github where people are using such method:

String postKey = getRef(position).getKey();

But in my Android S

相关标签:
1条回答
  • 2021-01-28 12:56

    There is no such function as getRef actually in Firebase API.

    So far I've understood that you're trying to put an onItemClickListener to your ListView and you're trying to pass some key to the ArticleDetailsActivity. So I think, as you've populated the articleModel list you can find the key in there.

    So the modified code might look like this.

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
            Intent intent = new Intent(getActivity(), ArticleDetailsActivity.class);
    
            // Find the key in the list you've populated earlier. 
            String postKey = articleModel.get(position).getKey();
    
            intent.putExtra(ArticleDetailsActivity.EXTRA_POST_KEY, postKey);
            getActivity().startActivity(intent);
        }
    });
    
    0 讨论(0)
提交回复
热议问题