質問

これが私のoncreateメソッドです:

    /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Intent intent = getIntent();
    if (intent.getData() == null)
        intent.setData(Formulas.CONTENT_URI);

    AutoCompleteTextView searchBar = (AutoCompleteTextView)findViewById(R.id.searchBar);
    Cursor c = getContentResolver().query(getIntent().getData(),new String[] { Formulas.TITLE }, null, null, null);
    SimpleCursorAdapter searchAdapter = 
        new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, c, 
                new String[] { Formulas.TITLE } , new int[] { android.R.id.text1} );
    searchBar.setAdapter(searchAdapter);
}

DatabaseOpenHelperにいくつかのサンプルデータを入力しました。

        @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE formula ( \n" +
                "_id INTEGER PRIMARY KEY AUTOINCREMENT, \n" +
                "title TEXT NOT NULL, \n" +
                "formula TEXT NOT NULL \n" +
                ");");
        db.execSQL("INSERT INTO formula VALUES ( \n" +
                "null, \"Pythagorean theorium\", \"a^2+b^2=c^2\" \n" +
                "); ");
        db.execSQL("INSERT INTO formula VALUES ( \n" +
                "null, \"Perimeter of a square\", \"l^2 * w^2\" \n" +
                "); ");
        db.execSQL("INSERT INTO formula VALUES ( \n" +
                "null, \"Area of a square\", \"l^4\" \n" +
                "); ");
    }

問題は、私がアダプターをに設定する場所です AutoCompleteTextView, 、私が使用して挿入した値を期待しています SQLiteDatabase.execSQL(String) 方法。しかし、何もありませんか?ドロップダウンボックスは表示さえしませんか?デバッグを使用して、それを見つけました Cursor 無効ではなく、アダプターもそうではありませんでした AutoCompleteTextView?何が問題なのでしょうか?私はすでに自分のContentSproviderを定義しています。

役に立ちましたか?

解決

コンテンツURIが欠陥があり、完全に私のせいだったため、クエリは何も返されませんでした。 ここ 再生スレッドです。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top