Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.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 游标适配器中的IF语句?_Java_Android_Sqlite_Cursor - Fatal编程技术网

Java 游标适配器中的IF语句?

Java 游标适配器中的IF语句?,java,android,sqlite,cursor,Java,Android,Sqlite,Cursor,from和to仅存在于if语句的范围内。否则就没有多大意义了——即使他们这样做了,他们的内容也将是未定义的,或者,在Java的情况下,为null并立即使你的应用程序崩溃 我不知道您想要完成什么,但您可能也希望if块中的两条语句位于底部。我在上面遇到一个错误。即使我在if之前定义了变量。可以使用上面的代码吗?。。。如果记录不对应,则使用if语句跳过记录对不起,这是我多年来第一次使用java。这是无IF语句的工作列表适配器的代码。我想防止记录被列出,除非特定字段与变量匹配。 private void

from和to仅存在于if语句的范围内。否则就没有多大意义了——即使他们这样做了,他们的内容也将是未定义的,或者,在Java的情况下,为null并立即使你的应用程序崩溃


我不知道您想要完成什么,但您可能也希望if块中的两条语句位于底部。

我在上面遇到一个错误。即使我在if之前定义了变量。可以使用上面的代码吗?。。。如果记录不对应,则使用if语句跳过记录对不起,这是我多年来第一次使用java。这是无IF语句的工作列表适配器的代码。我想防止记录被列出,除非特定字段与变量匹配。
private void datafill()
{
        Cursor notesCursor = mDbHelper.fetchAllNotes();
        startManagingCursor(notesCursor);

        /* JournalRowId is the row id from the first database containing all journal names
        All notes are kept in database 2. I want only the notes that correspond to each 
        journal to be listed, KEY_HOMEID is the non visible field that shows where 
        each note came from.

         * 
         */
       if (editjournalDbAdapter.KEY_HOMEID == journalRowId){
        String[] from =  new String[]{editjournalDbAdapter.KEY_HEIGHT};

        int[] to = new int[]{R.id.detail1};
      }
            //Error here "from" and "to" are not defined outside of if statement
        SimpleCursorAdapter notes = 
            new SimpleCursorAdapter(this, R.layout.journaldetailrow, notesCursor, from, to);
        setListAdapter(notes);
    }