android.widget.SimpleCursorAdapter类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中android.widget.SimpleCursorAdapter类的一些代码示例,展示了SimpleCursorAdapter类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SimpleCursorAdapter类的具体详情如下:
包路径:android.widget.SimpleCursorAdapter
类名称:SimpleCursorAdapter

SimpleCursorAdapter介绍

暂无

代码示例

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onViewCreated(View view, Bundle state) {
 super.onViewCreated(view, state);
 SimpleCursorAdapter adapter=
  new SimpleCursorAdapter(getActivity(),
              R.layout.row,
              null,
              new String[] {
                DatabaseHelper.TITLE,
                DatabaseHelper.PROFILE_IMAGE
              },
              new int[] { R.id.title, R.id.icon },
              0);
 adapter.setViewBinder(new QuestionBinder());
 setListAdapter(adapter);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testChangeCursor() {
 SimpleCursorAdapter adapter =
   new SimpleCursorAdapter(context, 1, null, new String[] {"name"}, new int[] {2}, 0);
 Cursor cursor = setUpDatabase();
 adapter.changeCursor(cursor);
 assertThat(adapter.getCursor()).isSameAs(cursor);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testSwapCursorToNull() {
 SimpleCursorAdapter adapter =
   new SimpleCursorAdapter(context, 1, null, new String[] {"name"}, new int[] {2}, 0);
 Cursor cursor = setUpDatabase();
 adapter.swapCursor(cursor);
 adapter.swapCursor(null);
 assertThat(adapter.getCursor()).isNull();
}

代码示例来源:origin: commonsguy/cw-omnibus

SpinnerAdapter buildPhonesAdapter(Activity a) {
  String[] PROJECTION=new String[] { Contacts._ID,
                       Contacts.DISPLAY_NAME,
                       Phone.NUMBER
                      };
  String[] ARGS={String.valueOf(Phone.TYPE_MOBILE)};
  Cursor c=a.managedQuery(Phone.CONTENT_URI,
              PROJECTION, Phone.TYPE+"=?",
              ARGS, Contacts.DISPLAY_NAME);
  
  SimpleCursorAdapter adapter=new SimpleCursorAdapter(a,
                  android.R.layout.simple_spinner_item,
                  c,
                  new String[] {
                   Contacts.DISPLAY_NAME
                  },
                  new int[] {
                   android.R.id.text1
                  });
                  
  adapter.setDropDownViewResource(
      android.R.layout.simple_spinner_dropdown_item);
  
  return(adapter);
 }
}

代码示例来源:origin: stackoverflow.com

ListAdapter adapter = new SimpleCursorAdapter(MyList, Layout, c, 
        new String[] { "Name", "Score" }, to) 
{ 
    public boolean areAllItemsEnabled() 
    { 
        return false; 
    } 
    public boolean isEnabled(int position) 
    { 
        return false; 
    } 
};

代码示例来源:origin: google/ringdroid

@Override
  public void onLoaderReset(Loader<Cursor> loader) {
    // This is called when the last Cursor provided to onLoadFinished()
    // above is about to be closed.  We need to make sure we are no
    // longer using it.
    mAdapter.swapCursor(null);
  }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Subscribe(sticky = true, threadMode =ThreadMode.MAIN)
public void onModelLoaded(ModelLoadedEvent event) {
 ((SimpleCursorAdapter)getListAdapter()).changeCursor(event.model);
 if (sv!=null) {
  sv.setEnabled(true);
 }
}

代码示例来源:origin: GeoODK/collect

private void showUnsent() {
  mShowUnsent = true;
  Cursor c = mShowUnsent ? getUnsentCursor() : getAllCursor();
  Cursor old = mInstances.getCursor();
  try {
    mInstances.changeCursor(c);
  } finally {
    if (old != null) {
      old.close();
      this.stopManagingCursor(old);
    }
  }
  getListView().invalidate();
}

代码示例来源:origin: ardovic/Open-Source-Android-Weather-App

@Override
protected void onDestroy() {
  super.onDestroy();
  if (mAdapter.getCursor() != null) {
    mAdapter.getCursor().close();
  }
  database.close();
  //mFetchThreadData.clearQueue();
}

代码示例来源:origin: stackoverflow.com

Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);
Cursor c1 = (some code for getting a cursor from an data source, for example, a sqlite database)
SimpleCursorAdapter adapter1 = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c1, new String[]{"column_name"}, new int[]{android.R.id.text1});
spinner1.setAdapter(adapter1);

Spinner spinner2 = (Spinner) findViewById(R.id.spinner2);
Cursor c2 = (some code for getting a cursor from an data source, for example, a sqlite database)
SimpleCursorAdapter adapter2 = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c2, new String[]{"column_name"}, new int[]{android.R.id.text1});
spinner2.setAdapter(adapter2);

spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {

  @Override
  public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    Cursor c_new = (create a new cursor); 
  adapter2.changeCursor(c_new);               
  adapter2.notifyDataSetChanged(); // this is important for notifying the UI
  spinner2.setAdapter(adapter2);
  }
});

代码示例来源:origin: com.novoda.imageloader/imageloader-demo

private void setAdapter() {
  SimpleCursorAdapter adapter = initAdapter();
  ViewBinder binder = getViewBinder();
  if (binder != null) {
    adapter.setViewBinder(binder);
  }
  view.setAdapter(adapter);
}

代码示例来源:origin: stackoverflow.com

SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null, from, to, 0) {
  @Override
  public boolean isEnabled(int position) {
    return false;
  }
};

代码示例来源:origin: commonsguy/cw-omnibus

SpinnerAdapter buildPhonesAdapter(Activity a) {
  String[] PROJECTION=new String[] {  Contacts.Phones._ID,
                    Contacts.Phones.NAME,
                    Contacts.Phones.NUMBER
                   };
  String[] ARGS={String.valueOf(Contacts.Phones.TYPE_MOBILE)};
  Cursor c=a.managedQuery(Contacts.Phones.CONTENT_URI,
              PROJECTION,
              Contacts.Phones.TYPE+"=?", ARGS,
              Contacts.Phones.NAME);
  
  SimpleCursorAdapter adapter=new SimpleCursorAdapter(a,
                  android.R.layout.simple_spinner_item,
                  c,
                  new String[] {
                   Contacts.Phones.NAME
                  },
                  new int[] {
                   android.R.id.text1
                  });
                  
  adapter.setDropDownViewResource(
      android.R.layout.simple_spinner_dropdown_item);
  
  return(adapter);
 }
}

代码示例来源:origin: google/ringdroid

@Override
  public void onLoaderReset(Loader<Cursor> loader) {
    // This is called when the last Cursor provided to onLoadFinished()
    // above is about to be closed.  We need to make sure we are no
    // longer using it.
    mAdapter.swapCursor(null);
  }
}

代码示例来源:origin: dsolonenko/financisto

public void onDestroy() {
  if (autoCompleteAdapter != null) {
    autoCompleteAdapter.changeCursor(null);
    autoCompleteAdapter = null;
  }
}

代码示例来源:origin: GeoODK/collect

private void showAll() {
  mShowUnsent = false;
  Cursor c = mShowUnsent ? getUnsentCursor() : getAllCursor();
  Cursor old = mInstances.getCursor();
  try {
    mInstances.changeCursor(c);
  } finally {
    if (old != null) {
      old.close();
      this.stopManagingCursor(old);
    }
  }
  getListView().invalidate();
}

代码示例来源:origin: google/ringdroid

private Uri getUri(){
  //Get the uri of the item that is in the row
  Cursor c = mAdapter.getCursor();
  int uriIndex = getUriIndex(c);
  if (uriIndex == -1) {
    return null;
  }
  String itemUri = c.getString(uriIndex) + "/" +
  c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media._ID));
  return (Uri.parse(itemUri));
}

代码示例来源:origin: stackoverflow.com

SimpleCursorAdapter simpleCursorAdapter = new SimpleCursorAdapter(..);
simpleCursorAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
  public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
    if(columnIndex == someColumnValue) {
        TextView text = (TextView) view;  // get your View
        text.setText(String.valueOf(cursor.getInt(1)/100));  //set some data
        return true;
    }
    return false;
  }
});

代码示例来源:origin: stackoverflow.com

SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(/* ur stuff */);
cursorAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
  public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
    if(columnIndex == 1) {
      CheckBox cb = (CheckBox) view;
      cb.setChecked(cursor.getInt(1) > 0);
      return true;
    }
    return false;
  }
});

代码示例来源:origin: robolectric/robolectric

@Test
public void testSwapCursor() {
 SimpleCursorAdapter adapter =
   new SimpleCursorAdapter(context, 1, null, new String[] {"name"}, new int[] {2}, 0);
 Cursor cursor = setUpDatabase();
 adapter.swapCursor(cursor);
 assertThat(adapter.getCursor()).isSameAs(cursor);
}

相关文章