use of android.widget.ListAdapter in project android_frameworks_base by AOSPA.
the class ListManagedCursor method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get a cursor with all people
Cursor c = getContentResolver().query(Settings.System.CONTENT_URI, null, null, null, null);
startManagingCursor(c);
ListAdapter adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view
android.R.layout.simple_list_item_1, // Give the cursor to the list adatper
c, // Map the NAME column in the people database to...
new String[] { People.NAME }, // The "text1" view defined in the XML template
new int[] { android.R.id.text1 });
setListAdapter(adapter);
getListView().setOnItemClickListener(this);
}
use of android.widget.ListAdapter in project android_frameworks_base by AOSPA.
the class SyncActivityTooManyDeletes method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
if (extras == null) {
finish();
return;
}
mNumDeletes = extras.getLong("numDeletes");
mAccount = (Account) extras.getParcelable("account");
mAuthority = extras.getString("authority");
mProvider = extras.getString("provider");
// the order of these must match up with the constants for position used in onItemClick
CharSequence[] options = new CharSequence[] { getResources().getText(R.string.sync_really_delete), getResources().getText(R.string.sync_undo_deletes), getResources().getText(R.string.sync_do_nothing) };
ListAdapter adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_list_item_1, android.R.id.text1, options);
ListView listView = new ListView(this);
listView.setAdapter(adapter);
listView.setItemsCanFocus(true);
listView.setOnItemClickListener(this);
TextView textView = new TextView(this);
CharSequence tooManyDeletesDescFormat = getResources().getText(R.string.sync_too_many_deletes_desc);
textView.setText(String.format(tooManyDeletesDescFormat.toString(), mNumDeletes, mProvider, mAccount.name));
final LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0);
ll.addView(textView, lp);
ll.addView(listView, lp);
// TODO: consider displaying the icon of the account type
// AuthenticatorDescription[] descs = AccountManager.get(this).getAuthenticatorTypes();
// for (AuthenticatorDescription desc : descs) {
// if (desc.type.equals(mAccount.type)) {
// try {
// final Context authContext = createPackageContext(desc.packageName, 0);
// ImageView imageView = new ImageView(this);
// imageView.setImageDrawable(authContext.getDrawable(desc.iconId));
// ll.addView(imageView, lp);
// } catch (PackageManager.NameNotFoundException e) {
// }
// break;
// }
// }
setContentView(ll);
}
use of android.widget.ListAdapter in project android_frameworks_base by AOSPA.
the class WatchHeaderListView method wrapAdapterIfNecessary.
private void wrapAdapterIfNecessary() {
ListAdapter adapter = getAdapter();
if (adapter != null && mTopPanel != null) {
if (!(adapter instanceof WatchHeaderListAdapter)) {
wrapHeaderListAdapterInternal();
}
((WatchHeaderListAdapter) getAdapter()).setTopPanel(mTopPanel);
dispatchDataSetObserverOnChangedInternal();
}
}
use of android.widget.ListAdapter in project android_frameworks_base by AOSPA.
the class CascadingMenuPopup method findParentViewForSubmenu.
/**
* Attempts to find the view for the menu item that owns the specified
* submenu.
*
* @param parentInfo info for the parent menu
* @param submenu the submenu whose parent view should be obtained
* @return the parent view, or {@code null} if one could not be found
*/
@Nullable
private View findParentViewForSubmenu(@NonNull CascadingMenuInfo parentInfo, @NonNull MenuBuilder submenu) {
final MenuItem owner = findMenuItemForSubmenu(parentInfo.menu, submenu);
if (owner == null) {
// Couldn't find the submenu owner.
return null;
}
// The adapter may be wrapped. Adjust the index if necessary.
final int headersCount;
final MenuAdapter menuAdapter;
final ListView listView = parentInfo.getListView();
final ListAdapter listAdapter = listView.getAdapter();
if (listAdapter instanceof HeaderViewListAdapter) {
final HeaderViewListAdapter headerAdapter = (HeaderViewListAdapter) listAdapter;
headersCount = headerAdapter.getHeadersCount();
menuAdapter = (MenuAdapter) headerAdapter.getWrappedAdapter();
} else {
headersCount = 0;
menuAdapter = (MenuAdapter) listAdapter;
}
// Find the index within the menu adapter's data set of the menu item.
int ownerPosition = AbsListView.INVALID_POSITION;
for (int i = 0, count = menuAdapter.getCount(); i < count; i++) {
if (owner == menuAdapter.getItem(i)) {
ownerPosition = i;
break;
}
}
if (ownerPosition == AbsListView.INVALID_POSITION) {
// Couldn't find the owner within the menu adapter.
return null;
}
// Adjust the index for the adapter used to display views.
ownerPosition += headersCount;
// Adjust the index for the visible views.
final int ownerViewPosition = ownerPosition - listView.getFirstVisiblePosition();
if (ownerViewPosition < 0 || ownerViewPosition >= listView.getChildCount()) {
// Not visible on screen.
return null;
}
return listView.getChildAt(ownerViewPosition);
}
use of android.widget.ListAdapter in project android_frameworks_base by ResurrectionRemix.
the class ListWithHeaders method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
final ListView listView = getListView();
listView.setItemsCanFocus(true);
for (int i = 0; i < 12; i++) {
Button header = new Button(this);
header.setText("Header View");
listView.addHeaderView(header);
}
for (int i = 0; i < 12; i++) {
Button footer = new Button(this);
footer.setText("Footer View");
listView.addFooterView(footer);
}
final ListAdapter adapter = listView.getAdapter();
listView.setAdapter(adapter);
}
Aggregations