Android with Firebase:尝试使用CardView实现RecycleView但无法检索RecycleView项目位置?

时间:2018-01-25 02:44:23

标签: java android firebase android-fragments firebase-realtime-database

我是初学者,尝试制作一个RecycleView布局,其中包含从Firebase数据库(<script> // DOM Ready $(function() { var $el, $ps, $up, totalHeight; $(".sidebar-box .button").click(function() { // IE 7 doesn't even get this far. I didn't feel like dicking with it. totalHeight = 0 $el = $(this); $p = $el.parent(); $up = $p.parent(); $ps = $up.find("p:not('.read-more')"); // measure how tall inside should be by adding together heights of all inside paragraphs (except read-more paragraph) $ps.each(function() { totalHeight += $(this).outerHeight(); // FAIL totalHeight += $(this).css("margin-bottom"); }); $up .css({ // Set height to prevent instant jumpdown when max height is removed "height": $up.height(), "max-height": 9999 }) .animate({ "height": totalHeight },500,function(){ //Callback - after the animation is over jQuery('#masonry-content').masonry(); }); // fade out read-more $p.fadeOut(); // prevent jump-down return false; }); }); )中检索的一些信息。在我的代码RecycleView布局与火基数据库的检索信息工作,但我无法检索项目列表位置,不能用于不同的按摩显示与用户选择/点击不同的项目列表可以任何人帮助我我怎么能做到这一点。 我的代码是: -

MemberFragment.java

2 个答案:

答案 0 :(得分:0)

要获得项目的位置,有两种解决方案。一个是:

Member member = listMemenbers.get(position);

如果您使用的是Member个对象的列表。第二:

Member member = memAdapter.getItem(position);

在这种情况下,您直接从适配器获取项目的位置。

答案 1 :(得分:0)

您可以简单地使用位置变量,即int位置,它将显示卡的位置或任何其他值

相关问题