當前位置: 首頁>>代碼示例>>Java>>正文


Java CursorAdapter類代碼示例

本文整理匯總了Java中android.support.v4.widget.CursorAdapter的典型用法代碼示例。如果您正苦於以下問題:Java CursorAdapter類的具體用法?Java CursorAdapter怎麽用?Java CursorAdapter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CursorAdapter類屬於android.support.v4.widget包,在下文中一共展示了CursorAdapter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    addNote(DEFAULT_NOTE_TITLE);

    Cursor cursor = getContentResolver().query(NoteProvider.CONTENT_URI, DBOpenHelper.ALL_COLUMNS, null, null, null, null);
    String[] from = {DBOpenHelper.NOTE_TEXT};
    int[] to  = {android.R.id.text1};
    CursorAdapter cursorAdapter = new SimpleCursorAdapter(this, android.R.simple_list_item1, cursor, from, to, 0);

    ListView list = (ListView) findViewById(android.R.id.list);
    list.setAdapter(cursorAdapter);
}
 
開發者ID:pH-7,項目名稱:Android-pH2Note-App,代碼行數:17,代碼來源:MainActivity.java

示例2: deleteAll

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
private void deleteAll(){
    ListView notesList = (ListView) findViewById(R.id.notes_list);
    CursorAdapter ca = (CursorAdapter) notesList.getAdapter();
    Cursor c = ca.getCursor();
    c.moveToPosition(-1);
    while (c.moveToNext()){
        if (c.getInt(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_TYPE)) == DbContract.NoteEntry.TYPE_AUDIO) {
            String filePath = getFilesDir().getPath()+"/audio_notes" + c.getString(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_CONTENT));
            new File(filePath).delete();
        } else if (c.getInt(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_TYPE)) == DbContract.NoteEntry.TYPE_SKETCH) {
            String content = c.getString(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_CONTENT));
            new File(getFilesDir().getPath()+"/sketches"+content).delete();
            new File(getFilesDir().getPath()+"/sketches"+content.substring(0, content.length()-3) + "jpg").delete();
        }
        DbAccess.deleteNote(getBaseContext(), c.getInt(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_ID)));
    }
    updateList();
}
 
開發者ID:SecUSo,項目名稱:privacy-friendly-notes,代碼行數:19,代碼來源:RecycleActivity.java

示例3: bindAdapterView

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
@Override
protected void bindAdapterView() {
	final ListAdapter oldAdapter = getAdapter();
	
	Cursor oldCursor = null;

	if (oldAdapter instanceof CursorAdapter) {
		oldCursor = ((CursorAdapter)oldAdapter).getCursor();
	}

	super.bindAdapterView();
	
	if (oldCursor != null) {
		swapCursor(oldCursor);
	}
}
 
開發者ID:dailystudio,項目名稱:devbricks,代碼行數:17,代碼來源:AbsCursorAdapterFragment.java

示例4: setSelectionById

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
public static boolean setSelectionById(final AdapterView spinner, final boolean loaded, long id, final String columnName, boolean setLastIfDidntFind) {
    if (loaded && id != AdapterView.INVALID_ROW_ID) {
        Cursor c = ((CursorAdapter) spinner.getAdapter()).getCursor();
        if (c != null) {
            int pos = 0;
            if (c.moveToFirst()) {
                final int index = c.getColumnIndex(columnName);
                do {
                    if (c.getLong(index) == id) {
                        spinner.setSelection(pos);
                        return true;
                    }
                    pos++;
                } while (c.moveToNext());
                if(setLastIfDidntFind) {
                    spinner.setSelection(--pos);
                }
            }
        }
    }
    return false;
}
 
開發者ID:SelvinPL,項目名稱:SyncFrameworkAndroid,代碼行數:23,代碼來源:AdapterViewHelper.java

示例5: setSelectionByValue

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
public static boolean setSelectionByValue(final AdapterView spinner, final boolean loaded, String value, final String columnName, boolean setLastIfDidntFind) {
    if (loaded && value != null) {
        Cursor c = ((CursorAdapter) spinner.getAdapter()).getCursor();
        if (c != null) {
            int pos = 0;
            if (c.moveToFirst()) {
                value = value.toLowerCase();
                final int index = c.getColumnIndex(columnName);
                do {
                    if (c.getString(index).toLowerCase().equals(value)) {
                        spinner.setSelection(pos);
                        return true;
                    }
                    pos++;
                } while (c.moveToNext());
                if(setLastIfDidntFind) {
                    spinner.setSelection(--pos);
                }
            }
        }
    }
    return false;
}
 
開發者ID:SelvinPL,項目名稱:SyncFrameworkAndroid,代碼行數:24,代碼來源:AdapterViewHelper.java

示例6: populateList

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
private void populateList() {

		String[] from = null;
		if (isFav) {
			from = new String[] { Beans.Favorite.COL_TITLE };
		} else {
			from = new String[] { Beans.Category.COL_NAME };
		} //check if fav or list
		int[] to = { R.id.list_item_text };
		int layoutId = R.layout.list_item;
		if (Preferences.getInstance(getActivity()).isRTL())
			layoutId = R.layout.list_item_right;
		
		getLoaderManager().initLoader(1, null, this);
		adapter = new SimpleCursorAdapter(getActivity(), layoutId, null, from,
				to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
		adapter.setViewBinder(new Binder());
		setListAdapter(adapter);
		adapter.notifyDataSetChanged();
	}
 
開發者ID:Barqawiz,項目名稱:Android_ApplicationTemplate,代碼行數:21,代碼來源:ListFrag.java

示例7: onCreate

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_logcat);

    LogLine.isScrubberEnabled = PreferenceHelper.isScrubberEnabled(this);

    handleShortcuts(getIntent().getStringExtra("shortcut_action"));

    mHandler = new Handler(Looper.getMainLooper());

    binding.fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogHelper.stopRecordingLog(LogcatActivity.this);
        }
    });

    binding.list.setLayoutManager(new LinearLayoutManager(this));

    binding.list.setItemAnimator(null);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_actionbar));
    setTitle(R.string.logcat);

    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(this);

    log.d("initial collapsed mode is %s", mCollapsedMode);

    mSearchSuggestionsAdapter = new SimpleCursorAdapter(this,
            R.layout.list_item_dropdown,
            null,
            new String[]{"suggestion"},
            new int[]{android.R.id.text1},
            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    setUpAdapter();
    updateBackgroundColor();
    runUpdatesIfNecessaryAndShowWelcomeMessage();
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:41,代碼來源:LogcatActivity.java

示例8: setSearchSuggestionAdapter

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
public static SimpleCursorAdapter setSearchSuggestionAdapter(Context context) {
    final String[] from = new String[]{"name"};
    final int[] to = new int[]{android.R.id.text1};
    SimpleCursorAdapter searchAdapter = new SimpleCursorAdapter(context, android.R.layout.simple_list_item_1, null, from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);


    final MatrixCursor c = new MatrixCursor(new String[]{BaseColumns._ID, "name"});
    for (int i = 0; i < SuperSearch.suggestions.length; i++) {
        c.addRow(new Object[]{i, SuperSearch.suggestions[i]});
    }
    searchAdapter.changeCursor(c);

    return searchAdapter;
}
 
開發者ID:pvarry,項目名稱:intra42,代碼行數:15,代碼來源:SuperSearch.java

示例9: MediaStoreAdapter

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
public MediaStoreAdapter(final Context context, final int id_layout) {
	super(context, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    mInflater = LayoutInflater.from(context);
    mCr = context.getContentResolver();
    mQueryHandler = new MyAsyncQueryHandler(mCr, this);
	// getMemoryClass return the available memory amounts for app as mega bytes(API >= 5)
	mMemClass = ((ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
	mLayoutId = id_layout;
	onContentChanged();
}
 
開發者ID:saki4510t,項目名稱:libcommon,代碼行數:11,代碼來源:MediaStoreAdapter.java

示例10: type

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
public static SubjectFactory<CursorAdapterSubject, CursorAdapter> type() {
  return new SubjectFactory<CursorAdapterSubject, CursorAdapter>() {
    @Override
    public CursorAdapterSubject getSubject(FailureStrategy fs, CursorAdapter that) {
      return new CursorAdapterSubject(fs, that);
    }
  };
}
 
開發者ID:pkware,項目名稱:truth-android,代碼行數:9,代碼來源:CursorAdapterSubject.java

示例11: onLoadFinished

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
  ((CursorAdapter) listView.getAdapter()).changeCursor(data);
  emptyText.setText(R.string.contact_selection_group_activity__no_contacts);
  if (data != null && data.getCount() < 40) listView.setFastScrollAlwaysVisible(false);
  else                                      listView.setFastScrollAlwaysVisible(true);
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:8,代碼來源:PushContactSelectionListFragment.java

示例12: CalendarCursorAdapter

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
public CalendarCursorAdapter(Context context) {
    super(context,
            R.layout.list_item_calendar,
            null,
            new String[]{CalendarContract.Calendars.CALENDAR_DISPLAY_NAME},
            new int[]{R.id.text_view_title},
            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
}
 
開發者ID:tortuvshin,項目名稱:yield,代碼行數:9,代碼來源:CalendarSelectionView.java

示例13: prepareSearchSuggestions

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
@Override
public void prepareSearchSuggestions(List<DrawerItemCategory> navigation) {
    final String[] from = new String[]{"categories"};
    final int[] to = new int[]{android.R.id.text1};

    searchSuggestionsAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1,
            null, from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    if (navigation != null && !navigation.isEmpty()) {
        for (int i = 0; i < navigation.size(); i++) {
            if (!searchSuggestionsList.contains(navigation.get(i).getName())) {
                searchSuggestionsList.add(navigation.get(i).getName());
            }

            if (navigation.get(i).hasChildren()) {
                for (int j = 0; j < navigation.get(i).getChildren().size(); j++) {
                    if (!searchSuggestionsList.contains(navigation.get(i).getChildren().get(j).getName())) {
                        searchSuggestionsList.add(navigation.get(i).getChildren().get(j).getName());
                    }
                }
            }
        }
        searchSuggestionsAdapter.notifyDataSetChanged();
    } else {
        Timber.e("Search suggestions loading failed.");
        searchSuggestionsAdapter = null;
    }
}
 
開發者ID:openshopio,項目名稱:openshop.io-android,代碼行數:28,代碼來源:MainActivity.java

示例14: deleteSelectedItems

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
private void deleteSelectedItems(){
    ListView notesList = (ListView) findViewById(R.id.notes_list);
    CursorAdapter adapter = (CursorAdapter) notesList.getAdapter();
    SparseBooleanArray checkedItemPositions = notesList.getCheckedItemPositions();
    for (int i=0; i < checkedItemPositions.size(); i++) {
        if(checkedItemPositions.valueAt(i)) {
            DbAccess.trashNote(getBaseContext(), (int) (long) adapter.getItemId(checkedItemPositions.keyAt(i)));
        }
    }
}
 
開發者ID:SecUSo,項目名稱:privacy-friendly-notes,代碼行數:11,代碼來源:MainActivity.java

示例15: updateList

import android.support.v4.widget.CursorAdapter; //導入依賴的package包/類
private void updateList() {
    ListView notesList = (ListView) findViewById(R.id.notes_list);
    CursorAdapter adapter = (CursorAdapter) notesList.getAdapter();
    String selection = DbContract.NoteEntry.COLUMN_TRASH + " = ?";
    String[] selectionArgs = { "1" };
    adapter.changeCursor(DbAccess.getCursorAllNotes(getBaseContext(), selection, selectionArgs));
}
 
開發者ID:SecUSo,項目名稱:privacy-friendly-notes,代碼行數:8,代碼來源:RecycleActivity.java


注:本文中的android.support.v4.widget.CursorAdapter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。