SimpleCursorAdapter의 하위 클래스를 어댑터로 사용하여 support lib의 ListFragment를 확장합니다. 모든 데이터로드 부분은 ok (디버그를 통해 읽음)이며 목록은 표시되지 않고 활동에 빈 페이지가 있습니다.android.support.v4.app.ListFragment가 표시되지 않습니다.
import android.support.v4.app.FragmentActivity;
public class HostActivity extends FragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_with_fragment);
}
}
레이아웃 파일 (activity_view_with_fragment.xml) :
import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
public class MyFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor>{
public void onActivityCreated(Bundle savedInstanceState){
super.onActivityCreated(savedInstanceState);
String [] from = new String[] {"col_1", "col_2"};
int [] to = new int [] {R.id.view1, R.id.view2};
//..put value in args
Loader l = getLoaderManager().restartLoader(0, args, this);
if(l != null)
l.forceLoad();
adapter = new CustomCursorAdapter(this.getActivity()
, R.layout.row_entry, null, from,
to, 0);
setListAdapter(adapter);
}
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
adapter.swapCursor(cursor);
}
public void onLoaderReset(Loader<Cursor> cursorLoader) {
adapter.swapCursor(null);
}
}
그리고 CustomCursorAdapter에서
, 내가 을 구현합니까 :<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/lsStopTimetableFragment"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="?android:attr/actionBarSize"
android:layout_weight="1"
class="com.package.Fragment.MyFragment">
</fragment>
</LinearLayout>
이것은 ListFragment 코드는 여기에 내 코드입니다
getView (int pos, View convertView, V 뷰 그룹 부모)
메서드. 어떤 팁? 미리 감사드립니다.
확실히 답하십시오! (점수 1을 가진 사용자의 굉장한 반응), 환호 :) –