Java 类android.widget.SimpleCursorAdapter 实例源码

项目:2017.2-codigo    文件:ContentConsumerSQLiteActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ContentResolver cr = getContentResolver();
    //consulta na main thread, pode ser custoso, usar AsyncTask ou Loader
    Cursor c = cr.query(ContentProviderContract.CONTENT_ESTADOS_URI, null, null, null, null);
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(
                    this,
                    R.layout.itemlista,
                    c,
                    new String[] {ContentProviderContract.STATE_NAME, ContentProviderContract.STATE_CODE},
                    new int[] {R.id.pNome, R.id.pEmail},
                    0);
    setListAdapter(adapter);
}
项目:2017.2-codigo    文件:ContentConsumerActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_content_consumer);
    ListView lv_pessoas = (ListView) findViewById(R.id.lv_Pessoas);
    ContentResolver cr = getContentResolver();
    //consulta na main thread, pode ser custoso, usar AsyncTask ou Loader
    Cursor c = cr.query(ContentProviderContract.CONTENT_LIST_URI, null, null, null, null);
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(
                    this,
                    R.layout.itemlista,
                    c,
                    new String[] {ContentProviderContract.NOME},
                    new int[] {R.id.pNome},
                    0);
    lv_pessoas.setAdapter(adapter);
}
项目:2017.2-codigo    文件:LerContatosLoaderActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String from[] = new String[]{ ContactsContract.Contacts.DISPLAY_NAME };
    int to[] = new int[]{ R.id.contactName };
    adapter = new SimpleCursorAdapter(
            getApplicationContext(),
            R.layout.contact,
            null,
            from,
            to,
            0);
    setListAdapter(adapter);
    getLoaderManager().initLoader(0, null, this);

}
项目:buildAPKsSamples    文件:Notepadv3.java   
private void fillData() {
    // Get all of the rows from the database and create the item list
    mNotesCursor = mDbHelper.fetchAllNotes();
    startManagingCursor(mNotesCursor);

    // Create an array to specify the fields we want to display in the list (only TITLE)
    String[] from = new String[]{NotesDbAdapter.KEY_TITLE};

    // and an array of the fields we want to bind those fields to (in this case just text1)
    int[] to = new int[]{R.id.text1};

    // Now create a simple cursor adapter and set it to display
    SimpleCursorAdapter notes = 
        new SimpleCursorAdapter(this, R.layout.notes_row, mNotesCursor, from, to);
    setListAdapter(notes);
}
项目:buildAPKsSamples    文件:Notepadv2.java   
private void fillData() {
    // Get all of the rows from the database and create the item list
    mNotesCursor = mDbHelper.fetchAllNotes();
    startManagingCursor(mNotesCursor);

    // Create an array to specify the fields we want to display in the list (only TITLE)
    String[] from = new String[]{NotesDbAdapter.KEY_TITLE};

    // and an array of the fields we want to bind those fields to (in this case just text1)
    int[] to = new int[]{R.id.text1};

    // Now create a simple cursor adapter and set it to display
    SimpleCursorAdapter notes = 
            new SimpleCursorAdapter(this, R.layout.notes_row, mNotesCursor, from, to);
    setListAdapter(notes);
}
项目:buildAPKsSamples    文件:Notepadv2.java   
private void fillData() {
    // Get all of the rows from the database and create the item list
    mNotesCursor = mDbHelper.fetchAllNotes();
    startManagingCursor(mNotesCursor);

    // Create an array to specify the fields we want to display in the list (only TITLE)
    String[] from = new String[]{NotesDbAdapter.KEY_TITLE};

    // and an array of the fields we want to bind those fields to (in this case just text1)
    int[] to = new int[]{R.id.text1};

    // Now create a simple cursor adapter and set it to display
    SimpleCursorAdapter notes = 
        new SimpleCursorAdapter(this, R.layout.notes_row, mNotesCursor, from, to);
    setListAdapter(notes);
}
项目:firebase-testlab-instr-lib    文件:NotesList.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);

    // If no data was given in the intent (because we were started
    // as a MAIN activity), then use our default content provider.
    Intent intent = getIntent();
    if (intent.getData() == null) {
        intent.setData(NoteColumns.CONTENT_URI);
    }

    // Inform the list we provide context menus for items
    getListView().setOnCreateContextMenuListener(this);

    // Perform a managed query. The Activity will handle closing and requerying the cursor
    // when needed.
    Cursor cursor = managedQuery(getIntent().getData(), PROJECTION, null, null,
                                    NoteColumns.DEFAULT_SORT_ORDER);

    // Used to map notes entries from the database to views
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.noteslist_item, cursor,
            new String[] { NoteColumns.TITLE }, new int[] { android.R.id.text1 });
    setListAdapter(adapter);
}
项目:okwallet    文件:SendingAddressesFragment.java   
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setHasOptionsMenu(true);

    adapter = new SimpleCursorAdapter(activity, R.layout.address_book_row, null,
            new String[] { AddressBookProvider.KEY_LABEL, AddressBookProvider.KEY_ADDRESS },
            new int[] { R.id.address_book_row_label, R.id.address_book_row_address }, 0);
    adapter.setViewBinder(new ViewBinder() {
        @Override
        public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) {
            if (!AddressBookProvider.KEY_ADDRESS.equals(cursor.getColumnName(columnIndex)))
                return false;

            ((TextView) view).setText(WalletUtils.formatHash(cursor.getString(columnIndex),
                    Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE));

            return true;
        }
    });
    setListAdapter(adapter);

    loaderManager.initLoader(0, null, this);
}
项目:AndiCar    文件:GPSTrackEditFragment.java   
@Override
protected void loadSpecificViewsFromLayoutXML() {
    tvTrackStats = mRootView.findViewById(R.id.tvTrackStats);
    ListView lvTrackFileList = mRootView.findViewById(R.id.lvTrackFileList);

    //statistics
    String selection = DBAdapter.COL_NAME_GPSTRACKDETAIL__GPSTRACK_ID + "=?";
    String[] selectionArgs = {Long.toString(mRowId)};
    int layout = R.layout.oneline_list_layout;

    //noinspection deprecation
    SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(getActivity(), layout, mDbAdapter.query(DBAdapter.TABLE_NAME_GPSTRACKDETAIL,
            DBAdapter.COL_LIST_GPSTRACKDETAIL_TABLE, selection, selectionArgs, DBAdapter.COL_NAME_GPSTRACKDETAIL__FILE),
            new String[]{DBAdapter.COL_NAME_GPSTRACKDETAIL__FILE}, new int[]{R.id.tvOneLineListTextSmall});

    lvTrackFileList.setAdapter(cursorAdapter);
}
项目:financisto1-holo    文件:TransactionUtils.java   
public static SimpleCursorAdapter createPayeeAdapter(Context context, DatabaseAdapter db) {
    final MyEntityManager em = db.em();
    return new SimpleCursorAdapter(context, android.R.layout.simple_dropdown_item_1line, null,
            new String[]{"e_title"}, new int[]{android.R.id.text1}){
        @Override
        public CharSequence convertToString(Cursor cursor) {
            return cursor.getString(cursor.getColumnIndex("e_title"));
        }

        @Override
        public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
            if (constraint == null) {
                return em.getAllPayees();
            } else {
                return em.getAllPayeesLike(constraint);
            }
        }
    };
}
项目:Mybilibili    文件:MySearchView.java   
/**
 * 关注1
 * 模糊查询数据 & 显示到ListView列表上
 */
private void queryData(String tempName) {

    // 1. 模糊搜索
    Cursor cursor = helper.getReadableDatabase().rawQuery(
            "select id as _id,name from Search where name like '%" + tempName + "%' order by id desc ", null);
    // 2. 创建adapter适配器对象 & 装入模糊搜索的结果
    adapter = new SimpleCursorAdapter(mContext, android.R.layout.simple_list_item_1, cursor, new String[] { "name" },
            new int[] { android.R.id.text1 }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    // 3. 设置适配器
    listView.setAdapter(adapter);
    adapter.notifyDataSetChanged();

    System.out.println(cursor.getCount());
    // 当输入框为空 & 数据库中有搜索记录时,显示 "删除搜索记录"按钮
    if (tempName.equals("") && cursor.getCount() != 0){
        tv_clear.setVisibility(VISIBLE);
    }
    else {
        tv_clear.setVisibility(INVISIBLE);
    };

}
项目:SmsScheduler    文件:SmsListActivity.java   
private SimpleCursorAdapter getSmsListAdapter() {
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(
            this,
            android.R.layout.simple_list_item_2,
            DbHelper.getDbHelper(this).getCursor(),
            new String[] { DbHelper.COLUMN_MESSAGE, DbHelper.COLUMN_RECIPIENT_NAME },
            new int[] { android.R.id.text1, android.R.id.text2 }
    );
    adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
        public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
            TextView textView = (TextView) view;
            if (textView.getId() == android.R.id.text2) {
                textView.setText(getFormattedSmsInfo(cursor));
                return true;
            }
            return false;
        }
    });
    return adapter;
}
项目:Android-Programming-for-Developers    文件:TagsFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    DataManager d = new DataManager(getActivity().getApplicationContext());
    Cursor c = d.getTags();

    // Create a new adapter
    SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(getActivity(),
            android.R.layout.simple_list_item_1, c,
            new String[] { DataManager.TABLE_ROW_TAG },
            new int[] { android.R.id.text1 }, 0);

    // Attach the Cursor to the adapter
    setListAdapter(cursorAdapter);
}
项目:Android-Programming-for-Developers    文件:TagsFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    DataManager d = new DataManager(getActivity().getApplicationContext());
    Cursor c = d.getTags();

    // Create a new adapter
    SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(getActivity(),
            android.R.layout.simple_list_item_1, c,
            new String[] { DataManager.TABLE_ROW_TAG },
            new int[] { android.R.id.text1 }, 0);

    // Attach the Cursor to the adapter
    setListAdapter(cursorAdapter);
}
项目:Android-Programming-for-Developers    文件:TagsFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    DataManager d = new DataManager(getActivity().getApplicationContext());
    Cursor c = d.getTags();

    // Create a new adapter
    SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(getActivity(),
            android.R.layout.simple_list_item_1, c,
            new String[] { DataManager.TABLE_ROW_TAG },
            new int[] { android.R.id.text1 }, 0);

    // Attach the Cursor to the adapter
    setListAdapter(cursorAdapter);
}
项目:Android-Programming-for-Developers    文件:TagsFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    DataManager d = new DataManager(getActivity().getApplicationContext());
    Cursor c = d.getTags();

    // Create a new adapter
    SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(getActivity(),
            android.R.layout.simple_list_item_1, c,
            new String[] { DataManager.TABLE_ROW_TAG },
            new int[] { android.R.id.text1 }, 0);

    // Attach the Cursor to the adapter
    setListAdapter(cursorAdapter);
}
项目:Search_Layout    文件:SearchView.java   
/**
 * 关注1
 * 模糊查询数据 & 显示到ListView列表上
 */
private void queryData(String tempName) {

    // 1. 模糊搜索
    Cursor cursor = helper.getReadableDatabase().rawQuery(
            "select id as _id,name from records where name like '%" + tempName + "%' order by id desc ", null);
    // 2. 创建adapter适配器对象 & 装入模糊搜索的结果
    adapter = new SimpleCursorAdapter(context, android.R.layout.simple_list_item_1, cursor, new String[] { "name" },
            new int[] { android.R.id.text1 }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    // 3. 设置适配器
    listView.setAdapter(adapter);
    adapter.notifyDataSetChanged();

    System.out.println(cursor.getCount());
    // 当输入框为空 & 数据库中有搜索记录时,显示 "删除搜索记录"按钮
    if (tempName.equals("") && cursor.getCount() != 0){
        tv_clear.setVisibility(VISIBLE);
    }
    else {
        tv_clear.setVisibility(INVISIBLE);
    };

}
项目:diva-android    文件:AccessControl3NotesActivity.java   
public void accessNotes(View view) {
    EditText pinTxt = (EditText) findViewById(R.id.aci3notesPinText);
    Button abutton = (Button) findViewById(R.id.aci3naccessbutton);
    SharedPreferences spref = PreferenceManager.getDefaultSharedPreferences(this);
    String pin = spref.getString(getString(R.string.pkey), "");
    String userpin = pinTxt.getText().toString();

    // XXX Easter Egg?
    if (userpin.equals(pin)) {
        // Display the private notes
        ListView  lview = (ListView) findViewById(R.id.aci3nlistView);
        Cursor cr = getContentResolver().query(NotesProvider.CONTENT_URI, new String[] {"_id", "title", "note"}, null, null, null);
        String[] columns = {NotesProvider.C_TITLE, NotesProvider.C_NOTE};
        int [] fields = {R.id.title_entry, R.id.note_entry};
        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.notes_entry ,cr, columns, fields, 0);
        lview.setAdapter(adapter);
        pinTxt.setVisibility(View.INVISIBLE);
        abutton.setVisibility(View.INVISIBLE);
        //cr.close();

    }
    else {
        Toast.makeText(this, "Please Enter a valid pin!", Toast.LENGTH_SHORT).show();
    }

}
项目:android-open-project-demo-master    文件:UserInfoActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "notes-db", null);
    db = helper.getWritableDatabase();
    daoMaster = new DaoMaster(db);
    daoSession = daoMaster.newSession();
    userInfoDao = daoSession.getNoteDao();

    String textColumn = UserInfoDao.Properties.Text.columnName;
    String orderBy = textColumn + " COLLATE LOCALIZED ASC";
    cursor = db.query(userInfoDao.getTablename(), userInfoDao.getAllColumns(), null, null, null, null, orderBy);
    String[] from = { textColumn, UserInfoDao.Properties.Comment.columnName };
    int[] to = { android.R.id.text1, android.R.id.text2 };

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, from,
            to);
    setListAdapter(adapter);

    editTextName = (EditText) findViewById(R.id.editTextName);
    editTextAge = (EditText) findViewById(R.id.editTextAge);
    addUiListeners();
}
项目:DiaryMemo    文件:DiaryMemoList.java   
/**
 * - 스플래시 화면이 표시되는 동안에 어떤 일(예를 들면 초기화  작업)을 시키려면 작업을 메인쓰레드가 아닌 다른 쓰레드에서 처리하도록 해야됨
 * - 메인 쓰레드는 스플래시 화면을 표시하는 일을 해야하니까.. 동시에 두개 작업은 할 수 없음
 */
@Override
public void onResume() {
    super.onResume();

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    boolean largeListItems = preferences.getBoolean("listItemSize", true);

    int sortOrder = Integer.valueOf(preferences.getString("sortOrder", "1"));
    boolean sortAscending = preferences.getBoolean("sortAscending", true);
    String sorting = DiaryMemo.SORT_ORDERS[sortOrder] + ((sortAscending ? " ASC" : " DESC"));

    @SuppressWarnings("deprecation")
    Cursor cursor = managedQuery(getIntent().getData(), PROJECTION, null, null, sorting);
    @SuppressWarnings("deprecation")
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
        (largeListItems) ? R.layout.row_large : R.layout.row_small,
        cursor, 
        new String[] { DiaryMemo.TITLE }, new int[] { android.R.id.text1 }
    );
    setListAdapter(adapter);

}
项目:DroidAssistant    文件:ShowSavedLocationActivity.java   
private void populateListViewFromDB() {
    String[] fromFieldNames = new String[]{DBhelper.PLACE_NAME, DBhelper.RADIUS, DBhelper.MODE};
    int[] toViewIDs = new int[]{R.id.place_name, R.id.radius, R.id.mode};
    Cursor cursor = sqlController.fetch();
    SimpleCursorAdapter myCursorAdapter =
            new SimpleCursorAdapter(
                    this,        // Context
                    R.layout.item_layout,    // Row layout template
                    cursor,                    // cursor (set of DB records to map)
                    fromFieldNames,            // DB Column names
                    toViewIDs                // View IDs to put information in
            );

    if (cursor.moveToFirst()) {
        myList.setAdapter(myCursorAdapter);

    } else {
        myList.setEmptyView(findViewById(R.id.empty_view));
    }
}
项目:tasktrckr    文件:MainActivityFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // For the cursor adapter, specify which columns go into which views
    String[] fromColumns = {TaskDatabaseHelper.TASK_TYPE};
    int[] toViews = {android.R.id.text1}; // The TextView in simple_list_item_1

    // Create an empty adapter we will use to display the loaded data.
    // We pass null for the cursor, then update it in onLoadFinished()
    mAdapter = new SimpleCursorAdapter(this.getActivity().getBaseContext(),
            android.R.layout.simple_list_item_1, null,
            fromColumns, toViews, 0);
    setListAdapter(mAdapter);

    return inflater.inflate(R.layout.task_list, container, false);
}
项目:android-cloud-test-lab    文件:NotesList.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);

    // If no data was given in the intent (because we were started
    // as a MAIN activity), then use our default content provider.
    Intent intent = getIntent();
    if (intent.getData() == null) {
        intent.setData(NoteColumns.CONTENT_URI);
    }

    // Inform the list we provide context menus for items
    getListView().setOnCreateContextMenuListener(this);

    // Perform a managed query. The Activity will handle closing and requerying the cursor
    // when needed.
    Cursor cursor = managedQuery(getIntent().getData(), PROJECTION, null, null,
                                    NoteColumns.DEFAULT_SORT_ORDER);

    // Used to map notes entries from the database to views
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.noteslist_item, cursor,
            new String[] { NoteColumns.TITLE }, new int[] { android.R.id.text1 });
    setListAdapter(adapter);
}
项目:flowzr-android-black    文件:TransactionUtils.java   
public static SimpleCursorAdapter createPayeeAdapter(Context context, DatabaseAdapter db) {
    final MyEntityManager em = db.em();
    return new SimpleCursorAdapter(context, android.R.layout.simple_dropdown_item_1line, null,
            new String[]{"e_title"}, new int[]{android.R.id.text1}){
        @Override
        public CharSequence convertToString(Cursor cursor) {
            return cursor.getString(cursor.getColumnIndex("e_title"));
        }

        @Override
        public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
            if (constraint == null) {
                return em.getAllPayees();
            } else {
                return em.getAllPayeesLike(constraint);
            }
        }
    };
}
项目:ODK-Liberia    文件:FormChooserList.java   
/**
   * Stores the path of selected form and finishes.
   */
  @Override
  protected void onListItemClick(ListView listView, View view, int position, long id) {
      // get uri to form
    long idFormsTable = ((SimpleCursorAdapter) getListAdapter()).getItemId(position);
      Uri formUri = ContentUris.withAppendedId(FormsColumns.CONTENT_URI, idFormsTable);

Collect.getInstance().getActivityLogger().logAction(this, "onListItemClick", formUri.toString());

      String action = getIntent().getAction();
      if (Intent.ACTION_PICK.equals(action)) {
          // caller is waiting on a picked form
          setResult(RESULT_OK, new Intent().setData(formUri));
      } else {
          // caller wants to view/edit a form, so launch formentryactivity
          startActivity(new Intent(Intent.ACTION_EDIT, formUri));
      }

      finish();
  }
项目:Android_Study_Demos    文件:NoteActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    DevOpenHelper helper = new DevOpenHelper(this, "notes-db", null);
    db = helper.getWritableDatabase();
    daoMaster = new DaoMaster(db);
    daoSession = daoMaster.newSession();
    noteDao = daoSession.getNoteDao();

    String textColumn = NoteDao.Properties.Text.columnName;
    String orderBy = textColumn + " COLLATE LOCALIZED ASC";
    cursor = db.query(noteDao.getTablename(), noteDao.getAllColumns(), null, null, null, null, orderBy);
    String[] from = { textColumn, NoteDao.Properties.Comment.columnName };
    int[] to = { android.R.id.text1, android.R.id.text2 };

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, from,
            to);
    setListAdapter(adapter);

    editText = (EditText) findViewById(R.id.editTextNote);
    Log.e("DaoExample", "tablename " + noteDao.getTablename());
    addUiListeners();
}
项目:restafari    文件:IpHistoryActivity.java   
@Override
protected void onCreate( Bundle savedInstanceState )
{
    super.onCreate( savedInstanceState );
    setContentView( R.layout.activity_test );

    ipsAdapter = new SimpleCursorAdapter(   this,
                                            android.R.layout.simple_list_item_2,
                                            null,
                                            new String[] { "ip", "timestampStr" },
                                            new int [] { android.R.id.text1, android.R.id.text2 },
                                            SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER
    );

    ((ListView)findViewById( R.id.ipListView )).setAdapter( ipsAdapter );

    swipeRefreshLayout = ((SwipeRefreshLayout)findViewById( R.id.swipRefresh ));
    swipeRefreshLayout.setOnRefreshListener( this );

    getLoaderManager().initLoader( IPS_LOADER, null, this );

    createRequest();
}
项目:bites-android    文件:MethodList.java   
@Override
protected void onResume() {
    super.onResume();

    /**Refresh the cursor using the selected recipe whenever the activity is resumed.
     * A new recipe can only be selected from the recipelist activity and 
     * this activity has to be resumed to display again so this should work fine. 
     */
    mCursor = managedQuery(Methods.CONTENT_URI, PROJECTION,
            Methods.RECIPE + "=" + Bites.mRecipeId, 
            null, Methods.DEFAULT_SORT_ORDER);

    // Used to map notes entries from the database to views
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.methodlist_item, mCursor,
        new String[] { Methods.STEP, Methods.TEXT}, 
        new int[] { R.id.methodstep, R.id.methodtext});
    setListAdapter(adapter);

    //Set the header text to the current recipe name
    mHeader.setText(Bites.mRecipeName);

}
项目:CC-Class3    文件:MainActivity.java   
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    urlText       = (EditText) findViewById(R.id.myUrl);
    //textView      = (TextView) findViewById(R.id.myText);
    listView      = (ListView) findViewById(R.id.listView);
    connectButton = (Button) findViewById(R.id.button);
    connectButton.setOnClickListener(this);
    try {
        myDatabaseManager.open();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    //myDatabaseManager.CreateDb();
    /*Cursor cursor = myDatabaseManager.GetCursor();
    SimpleCursorAdapter simpleCursorAdapter = new SimpleCursorAdapter(this,R.layout.simple_list_item_1,cursor,new String[] {"name","checked"}, new int[]{R.id.textView,R.id.textView2});
    listView.setAdapter(simpleCursorAdapter);*/
    Cursor cursor = myDatabaseManager.GetCursor();
    SimpleCursorAdapter simpleCursorAdapter = new SimpleCursorAdapter(this,R.layout.simple_list_item_1,cursor,new String[] {"name","checked"}, new int[]{R.id.textView,R.id.textView2});
    listView.setAdapter(simpleCursorAdapter);
}
项目:CC-Class3    文件:MainActivity.java   
protected void onPostExecute(String result) {
    try {
        String s = "";
        //JSONObject reader = new JSONObject(result);
        JSONArray jsonArray = new  JSONArray(result);

        for(int i = 0 ;i < jsonArray.length();i++)
        {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            //s=s+"Task is:" + jsonObject.optString("title").toString() + ". And state is:" + jsonObject.optString("completed").toString() + "\n";
            myDatabaseManager.DBInsert(jsonObject.optString("title").toString() , jsonObject.optString("completed").toString());
        }
        //textView.setText(s);
        //CursorLoader cursorLoader = new CursorLoader()
        Cursor cursor = myDatabaseManager.GetCursor();
        SimpleCursorAdapter simpleCursorAdapter = new SimpleCursorAdapter(context,R.layout.simple_list_item_1,cursor,new String[] {"name","checked"}, new int[]{R.id.textView,R.id.textView2});
        listView.setAdapter(simpleCursorAdapter);
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    //textView.setText(result);
}
项目:DailyMettaApp    文件:BookmarksFragmentC.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getListView().setEmptyView(getActivity().findViewById(R.id.empty_bookmarks_layout));

    getLoaderManager().initLoader(0, null, this);

    //Setting up the adapter..
    String[] tFromColumnsSg = new String[]{ArticleTableM.COLUMN_TITLE, ArticleTableM.COLUMN_TEXT, ArticleTableM.COLUMN_TIME_MONTH, ArticleTableM.COLUMN_TIME_DAYOFMONTH};
    int[] tToGuiIt = new int[]{R.id.favorite_row_title, R.id.favorite_row_quote, R.id.favorite_row_date_month, R.id.favorite_row_date_dayofmonth}; //-contained in the layout
    mAdapter = new SimpleCursorAdapter(getActivity(), R.layout.element_favorite_row, null, tFromColumnsSg, tToGuiIt, 0);
    mAdapter.setViewBinder(new FavoriteViewBinderM());

    //..adding it to the ListView contained within this activity
    setListAdapter(mAdapter);
}
项目:TP-Formation-Android    文件:ListContactsFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String[] fromColumns = {ContactsContract.Contacts.DISPLAY_NAME}; // Map colonnes et vues pour l’adapteur de curseur
    int[] toViews = {android.R.id.text1}; // La TextView dans simple_list_item_1
    // Requête sur le ContentProvider Contact pour obtenir un curseur sur les données
    mCursor = getActivity().getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
            PROJECTION, null, null, null);
    // Création d'un adapter basé sur cette requête
    mAdapter = new SimpleCursorAdapter(getActivity(),
            android.R.layout.simple_list_item_1, mCursor, fromColumns, toViews, 0);

    // Assignation de l'adapter à la liste du fragment
    setListAdapter(mAdapter);
}
项目:smartcells    文件:LocationActivity.java   
private void showAnalysis() {
    SmartCellsApplication app = ((SmartCellsApplication) getApplicationContext());
    // Column definition : SimpleCursorAdapter needs ID named "_id"
    String[] columns = new String[]{"_id", "col1", "col2"};

    MatrixCursor matrixCursor = new MatrixCursor(columns);
    startManagingCursor(matrixCursor);
    matrixCursor.addRow(new Object[]{1, "Global footprint\n[id,psc]=[count,avg]", "Location footprint\n[id,psc]=[count,avg]"});
    matrixCursor.addRow(new Object[]{2, app.currentFootprint.toString(), currentLocation.toString()});
    matrixCursor.addRow(new Object[]{3, "Common footprint", "Result"});
    matrixCursor.addRow(new Object[]{4, currentLocation.locationMatch.commonFootPrint.toString(), "C-" + currentLocation.locationMatch.currentCommonLocationsPercent + "% M-" + currentLocation.locationMatch.currentMatchPercent + "%"});

    String[] from = new String[]{"col1", "col2"};
    int[] to = new int[]{R.id.textViewCol1, R.id.textViewCol2};
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.table_item_footprint, matrixCursor, from, to, 0);
    ListView lv = (ListView) findViewById(R.id.lv);
    lv.setAdapter(adapter);
}
项目:Redpin    文件:GroupedListAdapter.java   
/**
 * {@inheritDoc}
 */
@Override
public int getItemViewType(int position) {
    int type = 1;
    for (Object section : this.sections.keySet()) {
        SimpleCursorAdapter adapter = sections.get(section);
        int size = adapter.getCount() + 1;

        // check if position inside this section
        if (position == 0)
            return TYPE_SECTION_HEADER;
        if (position < size)
            return type + adapter.getItemViewType(position - 1);

        // otherwise jump into next section
        position -= size;
        type += adapter.getViewTypeCount();
    }
    return -1;

}
项目:Redpin    文件:GroupedListAdapter.java   
/**
 * {@inheritDoc}
 */
@Override
public Object getItem(int position) {
    for (String section : this.sections.keySet()) {
        SimpleCursorAdapter adapter = sections.get(section);
        int size = adapter.getCount() + 1;

        // check if position inside this section
        if (position == 0)
            return section;
        if (position < size)
            return adapter.getItem(position - 1);

        // otherwise jump into next section
        position -= size;
    }
    return null;

}
项目:Redpin    文件:GroupedListAdapter.java   
/**
 * {@inheritDoc}
 */
@Override
public long getItemId(int position) {

    for (String section : this.sections.keySet()) {
        SimpleCursorAdapter adapter = sections.get(section);
        int size = adapter.getCount() + 1;

        // check if position inside this section
        if (position == 0)
            return 0;
        if (position < size)
            return adapter.getItemId(position - 1);

        // otherwise jump into next section
        position -= size;
    }
    return 0;
}
项目:Redpin    文件:GroupedListAdapter.java   
/**
 * {@inheritDoc}
 */
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    int sectionnum = 0;
    for (Object section : this.sections.keySet()) {
        SimpleCursorAdapter adapter = sections.get(section);
        int size = adapter.getCount() + 1;

        // check if position inside this section
        if (position == 0)
            return maps.getView(sectionnum, convertView, parent);
        if (position < size)
            return adapter.getView(position - 1, convertView, parent);

        // otherwise jump into next section
        position -= size;
        sectionnum++;
    }
    return null;

}
项目:ApkLauncher    文件:List2.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get a cursor with all people
    Cursor c = getContentResolver().query(Contacts.CONTENT_URI,
            CONTACT_PROJECTION, null, null, null);
    startManagingCursor(c);

    ListAdapter adapter = new SimpleCursorAdapter(this,
            // Use a template that displays a text view
            android.R.layout.simple_list_item_1,
            // Give the cursor to the list adatper
            c,
            // Map the NAME column in the people database to...
            new String[] {Contacts.DISPLAY_NAME},
            // The "text1" view defined in the XML template
            new int[] {android.R.id.text1});
    setListAdapter(adapter);
}
项目:ApkLauncher    文件:List7.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list_7);
    mPhone = (TextView) findViewById(R.id.phone);
    getListView().setOnItemSelectedListener(this);

    // Get a cursor with all numbers.
    // This query will only return contacts with phone numbers
    Cursor c = getContentResolver().query(Phone.CONTENT_URI,
            PHONE_PROJECTION, Phone.NUMBER + " NOT NULL", null, null);
    startManagingCursor(c);

    ListAdapter adapter = new SimpleCursorAdapter(this,
            // Use a template that displays a text view
            android.R.layout.simple_list_item_1,
            // Give the cursor to the list adapter
            c,
            // Map the DISPLAY_NAME column to...
            new String[] {Phone.DISPLAY_NAME},
            // The "text1" view defined in the XML template
            new int[] {android.R.id.text1});
    setListAdapter(adapter);
}
项目:ApkLauncher    文件:LoaderCursor.java   
@Override public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // Give some text to display if there is no data.  In a real
    // application this would come from a resource.
    setEmptyText("No phone numbers");

    // We have a menu item to show in action bar.
    setHasOptionsMenu(true);

    // Create an empty adapter we will use to display the loaded data.
    mAdapter = new SimpleCursorAdapter(getActivity(),
            android.R.layout.simple_list_item_2, null,
            new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS },
            new int[] { android.R.id.text1, android.R.id.text2 }, 0);
    setListAdapter(mAdapter);

    // Start out with a progress indicator.
    setListShown(false);

    // Prepare the loader.  Either re-connect with an existing one,
    // or start a new one.
    getLoaderManager().initLoader(0, null, this);
}