use of android.widget.ListAdapter in project android_frameworks_base by ParanoidAndroid.
the class ListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_activity);
ListAdapter adapter = new SimpleListAdapter(this);
ListView list = (ListView) findViewById(R.id.list);
list.setAdapter(adapter);
registerForContextMenu(list);
}
use of android.widget.ListAdapter in project android_frameworks_base by ParanoidAndroid.
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 UltimateAndroid by cymcsg.
the class DynamicListView method updateNeighborViewsForId.
/**
* Stores a reference to the views above and below the item currently
* corresponding to the hover cell. It is important to note that if this
* item is either at the top or bottom of the list, mAboveItemId or mBelowItemId
* may be invalid.
*/
private void updateNeighborViewsForId(long itemId) {
int position = getPositionForId(itemId);
ListAdapter adapter = getAdapter();
if (!adapter.hasStableIds()) {
throw new IllegalStateException("Adapter doesn't have stable ids! Make sure your adapter has stable ids, and override hasStableIds() to return true.");
}
mAboveItemId = position - 1 >= 0 ? adapter.getItemId(position - 1) : INVALID_ROW_ID;
mBelowItemId = position + 1 < adapter.getCount() ? adapter.getItemId(position + 1) : INVALID_ROW_ID;
}
use of android.widget.ListAdapter in project UltimateAndroid by cymcsg.
the class DynamicListView method swapElements.
private void swapElements(int indexOne, int indexTwo) {
mLastMovedToIndex = indexTwo;
ListAdapter adapter = getAdapter();
if (adapter instanceof HeaderViewListAdapter) {
adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter();
}
if (adapter instanceof Swappable) {
((Swappable) adapter).swapItems(indexOne - getHeaderViewsCount(), indexTwo - getHeaderViewsCount());
}
}
use of android.widget.ListAdapter in project UltimateAndroid by cymcsg.
the class SwipeLayout method isEnabledInAdapterView.
/**
* if working in {@link android.widget.AdapterView}, we should response {@link android.widget.Adapter}
* isEnable(int position).
* @return true when item is enabled, else disabled.
*/
private boolean isEnabledInAdapterView() {
AdapterView adapterView = getAdapterView();
boolean enable = true;
if (adapterView != null) {
Adapter adapter = adapterView.getAdapter();
if (adapter != null) {
int p = adapterView.getPositionForView(SwipeLayout.this);
if (adapter instanceof BaseAdapter) {
enable = ((BaseAdapter) adapter).isEnabled(p);
} else if (adapter instanceof ListAdapter) {
enable = ((ListAdapter) adapter).isEnabled(p);
}
}
}
return enable;
}
Aggregations