本文整理匯總了Java中android.support.v4.widget.SimpleCursorAdapter.setViewBinder方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleCursorAdapter.setViewBinder方法的具體用法?Java SimpleCursorAdapter.setViewBinder怎麽用?Java SimpleCursorAdapter.setViewBinder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.widget.SimpleCursorAdapter
的用法示例。
在下文中一共展示了SimpleCursorAdapter.setViewBinder方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initData
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
private void initData() {
final DataHelper dataHelper = new DataHelper(getActivity());
mSession = dataHelper.getActiveSessionId();
final String[] from = new String []{
Schema.COL_ID,
Schema.COL_BSSID,
Schema.COL_SSID,
"MAX(" + Schema.COL_LEVEL + ")",
/*Schema.COL_IS_NEW_WIFI,*/
Schema.COL_KNOWN_WIFI,
Schema.COL_CAPABILITIES};
final int[] to = new int [] {
R.id.wifilistfragment_id,
R.id.wifilistfragment_bssid,
R.id.wifilistfragment_ssid,
R.id.wifilistfragment_level,
R.id.wifilistfragment_statusicon,
R.id.wifilistfragment_capabilities};
mAdapter = new SimpleCursorAdapter(getActivity().getBaseContext(),
R.layout.wifilistitems, null, from, to, 0);
mAdapter.setViewBinder(new WifiViewBinder());
setListAdapter(mAdapter);
}
示例2: initData
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
/**
*
*/
private void initData() {
final DataHelper dataHelper = new DataHelper(getActivity());
mSession = dataHelper.getActiveSessionId();
final String[] from = new String[] {
Schema.COL_ACTUAL_CELLID,
Schema.COL_OPERATORNAME,
Schema.COL_NETWORKTYPE,
"MAX(" + Schema.COL_STRENGTHDBM + ")"
};
final int[] to = new int[] {
R.id.textViewCellID,
R.id.textViewOperator,
R.id.textViewNetworkType,
R.id.textViewStrenghtDbm
};
mAdapter = new SimpleCursorAdapter(getActivity().getBaseContext(),
R.layout.celllistitems, null, from, to, 0);
mAdapter.setViewBinder(new NetworkTypeDescriptionViewBinder());
setListAdapter(mAdapter);
}
示例3: onCreate
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.photo_selector_layout);
listView = (ListView) findViewById(android.R.id.list);
simpleCursorAdapter = new SimpleCursorAdapter(this, R.layout.photo_simple_list_item, null, STORE_IMAGES,
new int[] { R.id.item_title, R.id.item_value }, 0);
simpleCursorAdapter.setViewBinder(new ImageLocationBinder());
listView.setAdapter(simpleCursorAdapter);
// 注意此處是getSupportLoaderManager(),而不是getLoaderManager()方法。
getSupportLoaderManager().initLoader(0, null, this);
// 單擊顯示圖片
listView.setOnItemClickListener(new ShowItemImageOnClickListener());
// getAllAlbum();
getThumbnails();
}
示例4: populateList
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的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();
}
示例5: onActivityCreated
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
@Override
public void onActivityCreated(final Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
setEmptyText(getString(R.string.address_book_empty_text));
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()
{
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);
}
示例6: onActivityCreated
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
adapter = new SimpleCursorAdapter(getActivity(), R.layout.favoritesrow, null,
new String[]{Feeds.TITLE, Feeds.UNREAD},
new int[]{R.id.text2, R.id.text1}, 0);
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
@Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if (view.getId() == R.id.text1) {
if (cursor.getColumnIndex(Feeds.UNREAD) == columnIndex) {
((TextView) view).setText(Feeds.formatUnread(cursor.getInt(columnIndex)));
return true;
}
}
return false;
}
});
getLoaderManager().restartLoader(0, null, this);
registerForContextMenu(getListView());
}
示例7: onActivityCreated
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
String[] qstrings;
if (useMetricHeights) {
qstrings = new String[] { "Name", "Metres", "dateClimbed",
"hill_id" };
}
else {
qstrings = new String[] { "Name", "Feet", "dateClimbed", "hill_id" };
}
cursorAdapter = new SimpleCursorAdapter(getActivity(),
R.layout.simple_hill_item, null, qstrings, new int[] {
R.id.name_entry, R.id.number_entry,
R.id.check_hill_climbed, R.id.rowid },
0);
cursorAdapter.setViewBinder(new HillsViewBinder());
myListView.setAdapter(cursorAdapter);
myListView.setOnItemClickListener((parent, view, pos, id) -> {
// Extract the row id.
int rowId = Integer.parseInt(((TextView) (view
.findViewById(R.id.rowid))).getText().toString());
currentRowId = rowId;
hillSelectedListener.onHillSelected(rowId);
});
HillDetailFragment fragment = (HillDetailFragment) getActivity()
.getSupportFragmentManager().findFragmentById(
R.id.hill_detail_fragment);
}
示例8: onCreateView
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.activity_list_view, container, false);
// Attach the listeners to the ListView and add the footer
mListView = (ListView) v.findViewById(android.R.id.list);
mListView.setOnItemClickListener(this);
final View footer = inflater.inflate(R.layout.footer_list, mListView, false);
mListView.addFooterView(footer);
// Add the adapter to the listView
mAdapter = new SimpleCursorAdapter(getContext(), R.layout.library_menu_list_item, null, TO_PROJECTION, DEST_PROJECTION, 0);
mAdapter.setViewBinder(new LibraryBinder(getContext()));
mListView.setAdapter(mAdapter);
registerForContextMenu(mListView);
// Hide the nextPage and the retry buttons; these will not be used in this fragment
v.findViewById(R.id.story_load_pages).setVisibility(View.GONE);
v.findViewById(R.id.row_retry).setVisibility(View.GONE);
// The progress bar is used while the CursorLoader loads
mProgressBar = v.findViewById(R.id.progress_bar);
// Set the empty view
mEmptyView = (FrameLayout) v.findViewById(R.id.empty);
final TextView empty = new TextView(getActivity());
empty.setText(R.string.menu_library_no_stories);
empty.setGravity(Gravity.CENTER);
empty.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
mEmptyView.addView(empty);
setHasOptionsMenu(true);
return v;
}
示例9: populateList
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
public void populateList() {
String[] from = new String[] { DBAdapter.KEEP_TABLE.COL_DATA, DBAdapter.KEEP_TABLE.COL_COLOR };
int[] to = new int[] { R.id.textView1, R.id.item_color};
getLoaderManager().initLoader(1, null, this);
adapter = new SimpleCursorAdapter(getActivity(), R.layout.keep_item, null, from, to,
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
adapter.setViewBinder(new Binder());
setListAdapter(adapter);
adapter.notifyDataSetChanged();
}
示例10: onActivityCreated
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
@Override
public void onActivityCreated(final Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
setEmptyText(getString(R.string.address_book_empty_text));
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);
}
示例11: onActivityCreated
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
/**
* @link http://stackoverflow.com/questions/6317767/cant-add-a-headerview-to-a-listfragment
* Fragment lifecycle
* onAttach(Activity) called once the fragment is associated with its activity.
* onCreate(Bundle) called to do initial creation of the fragment.
* onCreateView(LayoutInflater, ViewGroup, Bundle) creates and returns the view hierarchy associated with the fragment.
* onActivityCreated(Bundle) tells the fragment that its activity has completed its own Activity.onCreate.
* onStart() makes the fragment visible to the user (based on its containing activity being started).
* onResume() makes the fragment interacting with the user (based on its containing activity being resumed).
*/
@Override
public final void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final String[] from = new String[] {
Schema.COL_ID,
Schema.COL_CREATED_AT,
Schema.COL_IS_ACTIVE,
Schema.COL_HAS_BEEN_EXPORTED,
Schema.COL_NUMBER_OF_CELLS,
Schema.COL_NUMBER_OF_WIFIS
};
final int[] to = new int[] {
R.id.sessionlistfragment_id,
R.id.sessionlistfragment_created_at,
R.id.sessionlistfragment_statusicon,
R.id.sessionlistfragment_uploadicon,
R.id.sessionlistfragment_no_cells,
R.id.sessionlistfragment_no_wifis};
mAdapter = new SimpleCursorAdapter(getActivity().getBaseContext(),
R.layout.sessionlistfragment, null, from, to, 0);
mAdapter.setViewBinder(new SessionViewBinder());
// Trying to add a Header View.
final View header = (View) getLayoutInflater(savedInstanceState).inflate(
R.layout.sessionlistheader, null);
this.getListView().addHeaderView(header);
// setup data adapters
setListAdapter(mAdapter);
getActivity().getSupportLoaderManager().initLoader(0, null, this);
// register for change notifications
mObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(final boolean selfChange) {
refreshAdapter();
};
};
getListView().setLongClickable(true);
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
getListView().setOnItemLongClickListener(new ActionModeUtils(
(ActionBarActivity) this.getActivity(), R.menu.session_context, this,
getListView()));
}
示例12: onActivityCreated
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
/**
* @link http://stackoverflow.com/questions/6317767/cant-add-a-headerview-to-a-listfragment
* Fragment lifecycle
* onAttach(Activity) called once the fragment is associated with its activity.
* onCreate(Bundle) called to do initial creation of the fragment.
* onCreateView(LayoutInflater, ViewGroup, Bundle) creates and returns the view hierarchy associated with the fragment.
* onActivityCreated(Bundle) tells the fragment that its activity has completed its own Activity.onCreate.
* onStart() makes the fragment visible to the user (based on its containing activity being started).
* onResume() makes the fragment interacting with the user (based on its containing activity being resumed).
*/
@Override
public final void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final String[] from = new String[] {
Schema.COL_ID,
Schema.COL_CREATED_AT,
Schema.COL_IS_ACTIVE,
Schema.COL_HAS_BEEN_EXPORTED,
Schema.COL_NUMBER_OF_CELLS,
Schema.COL_NUMBER_OF_WIFIS,
Schema.COL_NUMBER_OF_WAYPOINTS
};
final int[] to = new int[] {
R.id.sessionlistfragment_id,
R.id.sessionlistfragment_created_at,
R.id.sessionlistfragment_statusicon,
R.id.sessionlistfragment_uploadicon,
R.id.sessionlistfragment_no_cells,
R.id.sessionlistfragment_no_wifis,
R.id.sessionlistfragment_no_waypoints
};
mAdapter = new SimpleCursorAdapter(getActivity().getBaseContext(),
R.layout.sessionlistfragment, null, from, to, 0);
mAdapter.setViewBinder(new SessionViewBinder());
// Trying to add a Header View.
final View header = getLayoutInflater(savedInstanceState).inflate(
R.layout.sessionlistheader, null);
this.getListView().addHeaderView(header);
// setup data adapters
setListAdapter(mAdapter);
getActivity().getSupportLoaderManager().initLoader(0, null, this);
// register for change notifications
mObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(final boolean selfChange) {
refreshAdapter();
}
};
getListView().setLongClickable(true);
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
getListView().setOnItemLongClickListener(new ActionModeUtils(
(AppCompatActivity) this.getActivity(), R.menu.session_context, this,
getListView()));
}
示例13: onActivityCreated
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Intent intent = new Intent();
intent.setData(Notes.CONTENT_URI);
getListView().setOnCreateContextMenuListener(this);
mNoteListAdapter = new SimpleCursorAdapter(getActivity(),
R.layout.list_item_note, null,
new String[] {
Notes.TITLE,
Notes.MODIFIED_DATE
},
new int[] {
R.id._title,
R.id._created_time
},
0);
mNoteListAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if (columnIndex == NotesQuery.MODIFIED_DATE) {
long modified = cursor.getLong(NotesQuery.MODIFIED_DATE);
Date date = new Date(modified);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String text = simpleDateFormat.format(date);
((TextView) view).setText(text);
return true;
}
return false;
}
});
mNoteListView.setAdapter(mNoteListAdapter);
mManager = getLoaderManager();
mManager.restartLoader(NotesQuery.LOADER_ID, null, mLoaderCallbacks);
}