活动开始时,我在嵌套滚动视图内有三个回收器视图,它不加载第一个回收器视图。刷新所有回收站视图时,我已在应用程序中刷过“刷新布局”。在尝试每种解决方案的活动开始时,不会加载第二个回收者视图。
Java文件
shops.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot photosnapshot:dataSnapshot.getChildren())
{
Shops temp=photosnapshot.getValue(Shops.class);
Location templocation=new Location(LocationManager.GPS_PROVIDER);
Location templocation1=new Location(LocationManager.GPS_PROVIDER);
templocation.setLatitude(temp.getAddress().getLatitude());
templocation.setLongitude(temp.getAddress().getLongitude());
templocation1.setLatitude(common.currentLocation.getLatitude());
templocation1.setLongitude(common.currentLocation.getLongitude());
if(templocation.distanceTo(templocation1)<1500)
{
shopslist.add(new Shops(temp.getName(),temp.getImage(),temp.getStatus(),temp.getTimings(),temp.getAddress(),photosnapshot.getKey(),temp.getCategory()));
if(temp.getCategory().equals("02"))
{
dairyshoplist.add(new Shops(temp.getName(),temp.getImage(),temp.getStatus(),temp.getTimings(),temp.getAddress(),photosnapshot.getKey(),temp.getCategory()));
}
}
}
menuAdapter.notifyDataSetChanged();
recyclemenu= (RecyclerView) findViewById(R.id.recycler_menu);
recyclecategory=findViewById(R.id.recycler_menu_categories);
headerusername= (TextView) headerview.findViewById(R.id.textnameheader);
headerusername.setText(common.currentuser.getName());
recyclemenu.setHasFixedSize(true);
recyclecategory.setHasFixedSize(true);
layoutManager= new LinearLayoutManager(this);
layoutManager.setAutoMeasureEnabled(true);
recyclemenu.setLayoutManager(layoutManager);
recyclecategory.setLayoutManager(new GridLayoutManager(this,2));
recycle_dairy_shops.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true));
recycle_dairy_shops.setHasFixedSize(true);
recyclemenu.setNestedScrollingEnabled(false);
recycle_dairy_shops.setNestedScrollingEnabled(false);
recyclecategory.setNestedScrollingEnabled(false);
.xml文件
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/swipeLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.mahesh.door_step.Home"
tools:showIn="@layout/app_bar_home"
>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recycler_menu_categories"
android:fillViewport="true"
android:layout_below="@+id/search"
android:layout_marginTop="10dp"
android:scrollbars="vertical"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recycler_menu"
android:fillViewport="true"
android:layout_marginTop="10dp"
android:layout_below="@+id/recycler_menu_categories"
android:scrollbars="vertical"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recycler_menu_dairyshops"
android:fillViewport="true"
android:layout_marginTop="10dp"
android:layout_below="@+id/nearbyshopid"
android:scrollbars="vertical"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>