@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); }
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; } });
private void setAdapter() { SimpleCursorAdapter adapter = initAdapter(); ViewBinder binder = getViewBinder(); if (binder != null) { adapter.setViewBinder(binder); } view.setAdapter(adapter); }
@Override protected CursorAdapter createCursorAdapter() { SimpleCursorAdapter storageDomainListAdapter = new SimpleCursorAdapter(getActivity(), R.layout.storage_domain_list_item, null, new String[]{NAME, STATUS}, new int[]{R.id.storage_domain_name, R.id.storage_domain_status}, 0); storageDomainListAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { if (columnIndex == cursor.getColumnIndex(NAME)) { TextView textView = (TextView) view; String name = cursor.getString(cursor.getColumnIndex(NAME)); textView.setText(name); } else if (columnIndex == cursor.getColumnIndex(STATUS)) { ImageView imageView = (ImageView) view; String statusString = cursor.getString(cursor.getColumnIndex(STATUS)); imageView.setImageResource(StorageDomainStatus.fromString(statusString).getResource()); } return true; } }); return storageDomainListAdapter; }
@Override protected CursorAdapter createCursorAdapter() { SimpleCursorAdapter diskListAdapter = new SimpleCursorAdapter(getActivity(), R.layout.disk_list_item, null, new String[]{NAME, SIZE, STATUS}, new int[]{R.id.disk_name, R.id.disk_size, R.id.disk_status}, 0); diskListAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { TextView textView = (TextView) view; if (columnIndex == cursor.getColumnIndex(NAME)) { String name = cursor.getString(columnIndex); textView.setText(name); } else if (columnIndex == cursor.getColumnIndex(SIZE)) { long size = cursor.getLong(columnIndex); String sizeText = (size == -1) ? getString(R.string.disk_unknown_size) : new MemorySize(size).toString(); textView.setText(sizeText); } else if (columnIndex == cursor.getColumnIndex(STATUS)) { String status = cursor.getString(columnIndex); textView.setText(status == null ? getString(R.string.NA) : status.toUpperCase()); } return true; } }); return diskListAdapter; }
@Override protected CursorAdapter createCursorAdapter() { SimpleCursorAdapter snapshotListAdapter = new SimpleCursorAdapter(getActivity(), R.layout.snapshot_list_item, null, new String[]{NAME, SNAPSHOT_STATUS, DATE, PERSIST_MEMORYSTATE}, new int[]{R.id.snapshot_description, R.id.snapshot_status, R.id.snapshot_date, R.id.snapshot_persist_memorystate}, 0); snapshotListAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { TextView textView = (TextView) view; if (columnIndex == cursor.getColumnIndex(NAME)) { String name = cursor.getString(columnIndex); textView.setText(name); } else if (columnIndex == cursor.getColumnIndex(DATE)) { String date = DateUtils.convertDateToString(getActivity(), cursor.getLong(columnIndex)); textView.setText(date); } else if (columnIndex == cursor.getColumnIndex(SNAPSHOT_STATUS)) { String status = cursor.getString(columnIndex); textView.setText(status == null ? getString(R.string.NA) : status.replace("_", " ").toUpperCase()); } else if (columnIndex == cursor.getColumnIndex(PERSIST_MEMORYSTATE)) { textView.setText(getString(R.string.snapshot_memory)); textView.setVisibility((new CursorHelper(cursor)).getBoolean(columnIndex) ? View.VISIBLE : View.GONE); } return true; } }); return snapshotListAdapter; }
@Override protected CursorAdapter createCursorAdapter() { SimpleCursorAdapter diskListAdapter = new SimpleCursorAdapter(getActivity(), R.layout.disk_list_item, null, new String[]{NAME, SIZE, STATUS}, new int[]{R.id.disk_name, R.id.disk_size, R.id.disk_status}, 0); diskListAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { TextView textView = (TextView) view; if (columnIndex == cursor.getColumnIndex(NAME)) { String name = cursor.getString(columnIndex); textView.setText(name); } else if (columnIndex == cursor.getColumnIndex(SIZE)) { long size = cursor.getLong(columnIndex); String sizeText = (size == -1) ? getString(R.string.disk_unknown_size) : new MemorySize(size).toString(); textView.setText(sizeText); } else if (columnIndex == cursor.getColumnIndex(STATUS)) { String status = cursor.getString(columnIndex); textView.setText(status == null ? getString(R.string.NA) : status.toUpperCase()); } return true; } }); return diskListAdapter; }
new int[]{R.id.name, R.id.status, R.id.statistics}, 0); hostListAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
new String[]{NAME, STATUS, CPU_USAGE}, new int[]{R.id.name, R.id.status, R.id.statistics}, 0); vmListAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
new String[]{NAME, LINKED, PLUGGED}, new int[]{R.id.nic_mac, R.id.nic_status, R.id.nic_para}, 0); nicListAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
new String[]{NAME, LINKED, PLUGGED}, new int[]{R.id.nic_mac, R.id.nic_status, R.id.nic_para}, 0); nicListAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
new int[] { android.R.id.text1, android.R.id.text2 }); adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
new int[] { android.R.id.text1, android.R.id.text2 }); adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(Constants.TAG, "onCreateView"); View view = super.onCreateView(inflater, container, savedInstanceState); Context context = getActivity().getApplicationContext(); this.simpleCursorAdapter = new SimpleCursorAdapter(context, R.layout.row, null, new String[] { DatabaseHelper.NOTIFICATIONS_MESSAGE_COL, DatabaseHelper.NOTIFICATIONS_TIMESTAMP_COL }, new int[] { R.id.messageTextView, R.id.timestampTextView }); this.simpleCursorAdapter.setViewBinder(new NotificationViewBinder(context)); setListAdapter(this.simpleCursorAdapter); getLoaderManager().initLoader(0, null, this); return view; }
new String[]{NAME, STATUS}, new int[]{R.id.vm_name, R.id.vm_status}, 0); vmListAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
new int[]{R.id.sudoku_board, R.id.state, R.id.time, R.id.last_played, R.id.created, R.id.note}); mAdapter.setViewBinder(new SudokuListViewBinder(this)); updateList(); setListAdapter(mAdapter);
0); mAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { public boolean setViewValue(View view, Cursor cursor,
/** * */ 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, Schema.COL_AREA }; final int[] to = new int[] { R.id.textViewCellID, R.id.textViewOperator, R.id.textViewNetworkType, R.id.textViewArea }; mAdapter = new SimpleCursorAdapter(getActivity().getBaseContext(), R.layout.celllistitems, null, from, to, 0); mAdapter.setViewBinder(new NetworkTypeDescriptionViewBinder()); setListAdapter(mAdapter); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.folder_list); View getMorePuzzles = (View) findViewById(R.id.get_more_puzzles); setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT); // Inform the list we provide context menus for items getListView().setOnCreateContextMenuListener(this); getMorePuzzles.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://opensudoku.moire.org")); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); mDatabase = new SudokuDatabase(getApplicationContext()); mCursor = mDatabase.getFolderList(); startManagingCursor(mCursor); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.folder_list_item, mCursor, new String[]{FolderColumns.NAME, FolderColumns._ID}, new int[]{R.id.name, R.id.detail}); mFolderListBinder = new FolderListViewBinder(this); adapter.setViewBinder(mFolderListBinder); setListAdapter(adapter); // show changelog on first run Changelog changelog = new Changelog(this); changelog.showOnFirstRun(); }
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); }