use of android.widget.ListAdapter in project android_frameworks_base by ResurrectionRemix.
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 UltimateAndroid by cymcsg.
the class FloatingActionButtonDemo method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.floating_action_button_demo);
FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.button_floating_action);
floatingActionButton.attachToListView(getListView());
ListAdapter listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.countries));
getListView().setAdapter(listAdapter);
}
use of android.widget.ListAdapter in project UltimateAndroid by cymcsg.
the class ActivityTransitionActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_transition_first);
ListView list = (ListView) this.findViewById(R.id.listView);
ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, _animationList);
list.setAdapter(adapter);
list.setOnItemClickListener(this);
}
use of android.widget.ListAdapter in project UltimateAndroid by cymcsg.
the class DragSortListView method getChildHeight.
private int getChildHeight(int position) {
if (position == mSrcPos) {
return 0;
}
View v = getChildAt(position - getFirstVisiblePosition());
if (v != null) {
// hence the "true"
return getChildHeight(position, v, false);
} else {
// item is offscreen
// first check cache for child height at this position
int childHeight = mChildHeightCache.get(position);
if (childHeight != -1) {
// Log.d("mobeta", "found child height in cache!");
return childHeight;
}
final ListAdapter adapter = getAdapter();
int type = adapter.getItemViewType(position);
// There might be a better place for checking for the following
final int typeCount = adapter.getViewTypeCount();
if (typeCount != mSampleViewTypes.length) {
mSampleViewTypes = new View[typeCount];
}
if (type >= 0) {
if (mSampleViewTypes[type] == null) {
v = adapter.getView(position, null, this);
mSampleViewTypes[type] = v;
} else {
v = adapter.getView(position, mSampleViewTypes[type], this);
}
} else {
// type is HEADER_OR_FOOTER or IGNORE
v = adapter.getView(position, null, this);
}
// current child height is invalid, hence "true" below
childHeight = getChildHeight(position, v, true);
// cache it because this could have been expensive
mChildHeightCache.add(position, childHeight);
return childHeight;
}
}
use of android.widget.ListAdapter in project zxing by zxing.
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