1

私はまだ Android でシンを実行する最善の方法を学んでいますが、解決できない問題があります。私は数時間理解しようとしており、機能するスニペットを見つけようとしましたが、これを機能させることはできません。

データベース アクセスをカプセル化するために ContentProvider を作成しました (ContentProvider がなくてもこれを実行できたことはわかっていますが、学習したいと思います :) )。

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(android.R.layout.simple_list_item_activated_1, container, false);
    String[] projection = { CustomerDatabaseHelper.Col_name };
    int[] uiBindTo = { android.R.id.text1 };

    Cursor cursor = getActivity().getContentResolver().query(CustomerContentProvider.CONTENT_URI,
            projection, null, null, null); // CustomerDatabaseHelper.Col_name+" ASC"
    getLoaderManager().initLoader(CUSTOMER_LIST_LOADER, null, this);
    adapter = new SimpleCursorAdapter(
            getActivity().getApplicationContext(),
            android.R.layout.simple_list_item_activated_1, cursor,
            projection, uiBindTo,
            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    setListAdapter(adapter);
    return view;
}

カーソルパラメータにnullを入れると機能しますが、順序付けられたリストは提供されません。リストをソートするカーソルを作成しました。パラメータに入れると、アプリケーションが次のメッセージでクラッシュします: view.InflateException: バイナリ XML ファイルの 24 行目: クラス フラグメントの拡張中にエラーが発生しました

誰かが私を助けてくれることを願っています。

ヒューゴ

4

0 に答える 0