开发者

An IF statement in a cursor adapter?

开发者 https://www.devze.com 2023-01-07 18:44 出处:网络
private void datafill() { Cursor notesCursor = mDbHelper.fe开发者_如何学编程tchAllNotes(); startManagingCursor(notesCursor);
private void datafill()
{
        Cursor notesCursor = mDbHelper.fe开发者_如何学编程tchAllNotes();
        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);
    }


"from" and "to" only exist within the scope of the if() statement. Wouldn't make much sense otherwise anyway - even if they did, their contents would be undefined (or, in case of Java, null) and immediately crash your app.

I have no idea what you're trying to accomplish, but you probably want the bottom two statements inside the if() block as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号