Skip to content

Instantly share code, notes, and snippets.

Avatar

Dinabandhu Mondal dinabandhuM

View GitHub Profile
@dinabandhuM
dinabandhuM / ListViewWithScrollView.java
Created Sep 1, 2015
ListView and ScrollView will simultaneously get scroll
View ListViewWithScrollView.java
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 Aug 26, 2015
ViewHolder for list and grid view android
View viewholder.java
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);
}