"목록을 비우면"새로 고침을 추가했습니다. 목록이 비어 있으면 빈보기를 추가하려고합니다. 이제이 오류가 발생합니다. 이 작품을 어떻게 만들 수 있습니까? 메신저가 swipeRefresh 외부에 뷰를 위치시킨 다음 emptyView로 추가하면 작동합니다. 그래서 어떻게 외부 XML 파일로 할 수 있습니까?SwipeRefreshLayout은 하나의 직접 자식 만 호스팅 할 수 있습니다.
XML 코드 :
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:clipToPadding="false"
android:paddingBottom="@dimen/inbox_vertical_margin" ></ListView>
</android.support.v4.widget.SwipeRefreshLayout>
onCreateView :
View rootView = inflater.inflate(R.layout.fragment_inbox, container,
false);
View empty = inflater.inflate(R.layout.empty_message_list, container,
false);
ListView mListView = (ListView) rootView
.findViewById(android.R.id.list);
((ViewGroup) mListView.getParent()).addView(empty);
TextView textViewToChange = (TextView) empty
.findViewById(R.id.welcomeMessage);
textViewToChange.setText("YO "
+ ParseUser.getCurrentUser().getString(
ParseConstants.KEY_PRESENTING_USERNAME)
+ "! bad news.. :(");
mListView.setEmptyView(empty);
mSwipeRefreshLayout = (SwipeRefreshLayout) rootView
.findViewById(R.id.swipeRefreshLayout);
mSwipeRefreshLayout.setOnRefreshListener(mOnRefreshListener);
mSwipeRefreshLayout.setColorScheme(R.color.swipeRefresh1,
R.color.swipeRefresh2, R.color.swipeRefresh3,
R.color.swipeRefresh4);
return rootView;
나는 똑같은 문제에 직면 해 있었고, 하나의 자식 인 listview를 하나만 사용하고 있지만 괜찮 았지만 가시성을 숨기고있을 수도 있다는 것을 알았습니다. 그게 내 끝에서 실수를 저지른 것입니다. –