Skip to content

Instantly share code, notes, and snippets.

@dinabandhuM
dinabandhuM / ListViewWithScrollView.java
Created September 1, 2015 10:01
ListView and ScrollView will simultaneously get scroll
lv.setOnTouchListener(new ListView.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow ScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(true);
break;
@dinabandhuM
dinabandhuM / viewholder.java
Last active August 26, 2015 11:01
ViewHolder for list and grid view android
protected static class ViewHolderProductList {
// I added a generic return type to reduce the casting noise in client
// code
@SuppressWarnings("unchecked")
public static <T extends View> T get(View view, int id) {
SparseArray<View> viewHolder = (SparseArray<View>) view.getTag();
if (viewHolder == null) {
viewHolder = new SparseArray<View>();
view.setTag(viewHolder);
}