Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java AutoCompleteTextView适配器未显示下拉列表?_Java_Android_Sqlite_Android Contentprovider_Autocompletetextview - Fatal编程技术网

Java AutoCompleteTextView适配器未显示下拉列表?

Java AutoCompleteTextView适配器未显示下拉列表?,java,android,sqlite,android-contentprovider,autocompletetextview,Java,Android,Sqlite,Android Contentprovider,Autocompletetextview,以下是我的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 (in

以下是我的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);
}
我确实在数据库OpenHelper中输入了一些示例数据:

        @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)
方法插入的值。但是什么都没有?下拉框甚至没有出现?我使用了调试,发现
光标
不是空的,适配器或
自动完成文本视图
也不是空的?有什么问题吗?我已经定义了自己的contentprovider。

查询没有返回任何内容,因为内容uri有错误,完全是我的错误。是相关线程。

为什么sql查询中有
\n
和其他内容?还有,错误是什么?发布堆栈跟踪或错误message@Falmarri对不起,我不清楚。我使用ORM创建数据库创建方法,然后将其粘贴到eclipse中并自动格式化。没有错误。当我为AutoCompleteTextView设置适配器时,我希望在下拉框中显示“正方形的面积”、“勾股定理”和“正方形的周长”。但什么也没发生。