我的布局中有一些TextViews RecyclerView,基于我从Firebase数据库中获取的数据,我使用下面的代码隐藏了一些行,
public void Date(String d){
dataRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
LatLonConstructor data = dataSnapshot.getValue(LatLonConstructor.class);
LatLong = data.getLatLon();
String SplitOldLatlon[] = LatLong.split(" ");
Double OldLat = Double.parseDouble(SplitOldLatlon[0]);
Double OldLon = Double.parseDouble(SplitOldLatlon[1]);
String LatLon1 = location.getText().toString().trim();
String SplitNewLatlon[] = LatLon1.split(" ");
Double NewLat = Double.parseDouble(SplitNewLatlon[0]);
Double NewLon = Double.parseDouble(SplitNewLatlon[1]);
double Theta = NewLon - OldLon;
double dist = Math.sin(deg2rad(NewLat))
* Math.sin(deg2rad(OldLat))
+ Math.cos(deg2rad(NewLat))
* Math.cos(deg2rad(OldLat))
* Math.cos(deg2rad(Theta));
dist = Math.acos(dist);
dist = rad2deg(dist);
dist = dist * 60 * 1.1515;
String FinalDist = String.valueOf(dist);
body.setText(FinalDist);
dist = dist * 1.609;
if (dist < 1){
int pos = getAdapterPosition();
view.setVisibility(View.GONE);
view.setLayoutParams(new RecyclerView.LayoutParams(0,0));
progressDialog.dismiss();
} else {
progressDialog.dismiss();
}
}
现在的问题是它隐藏了视图,但是隐藏元素的地方留下了一个空白区域。
我想知道如何正确隐藏RecyclerView的项目。
海绵宝宝撒
慕村9548890
富国沪深
相关分类