当前位置: 首页>>代码示例>>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;未经允许,请勿转载。