我正在尝试使用解析查询适配器填充列表,但它始终为空。我正在按照解析(https://parse.com/tutorials/parse-query-adapter)提供的教程。如果我做错了,请告诉我。我怎样才能使它工作?谢谢
public class BrandsFragment extends Fragment {
private ParseQueryAdapter mainAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
mainAdapter = new ParseQueryAdapter(getActivity(), "Brands");
mainAdapter.setTextKey("BrandName");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_brands, container, false);
ListView listFollowingView = (ListView) rootView.findViewById(R.id.brands_list);
brands_list.setAdapter(mainAdapter);
mainAdapter.loadObjects();
if(mainAdapter.isEmpty()){
Toast.makeText(getActivity(),"EMPTY",Toast.LENGTH_SHORT).show();
}
}
}
布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.swipeit.swipeit.BrandsActivity$PlaceholderFragment">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/brands_list" />
</RelativeLayout>