use of android.widget.ListAdapter in project android_frameworks_base by DirtyUnicorns.
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);
}
use of android.widget.ListAdapter in project cw-omnibus by commonsguy.
the class LoremSearch method makeMeAnAdapter.
@Override
ListAdapter makeMeAnAdapter(Intent intent) {
ListAdapter adapter = null;
if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
String query = intent.getStringExtra(SearchManager.QUERY);
List<String> results = searchItems(query);
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, results);
setTitle("LoremSearch for: " + query);
}
return (adapter);
}
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 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 weex-example by KalicyZhou.
the class LoadPackagesAsyncTask method onPostExecute.
@Override
protected void onPostExecute(final List<AppInfo> results) {
ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity, R.layout.app_picker_list_item, R.id.app_picker_list_item_label, results) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
Drawable icon = results.get(position).getIcon();
if (icon != null) {
((ImageView) view.findViewById(R.id.app_picker_list_item_icon)).setImageDrawable(icon);
}
return view;
}
};
activity.setListAdapter(listAdapter);
}
Aggregations