Amazing Tutorials for Android Developers...

Monday, June 10, 2013

Horizontal ListView Tutorial

This is a ListView but it is Horizontal scrolling preferred. It containing image,button,and textView.
Get Reference from DEV-SMART, Origional post http://www.dev-smart.com/archives/34 here.

HorizontalListView.java

package com.sandy.demo;

import java.util.LinkedList;
import java.util.Queue;

import android.content.Context;
import android.database.DataSetObserver;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.Scroller;

public class HorizontalListView extends AdapterView<ListAdapter> {

    public boolean mAlwaysOverrideTouch = true;
    protected ListAdapter mAdapter;
    private int mLeftViewIndex = -1;
    private int mRightViewIndex = 0;
    protected int mCurrentX;
    protected int mNextX;
    private int mMaxX = Integer.MAX_VALUE;
    private int mDisplayOffset = 0;
    protected Scroller mScroller;
    private GestureDetector mGesture;
    private Queue<View> mRemovedViewQueue = new LinkedList<View>();
    private OnItemSelectedListener mOnItemSelected;
    private OnItemClickListener mOnItemClicked;
    private OnItemLongClickListener mOnItemLongClicked;
    private boolean mDataChanged = false;
   

    public HorizontalListView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }
   
    private synchronized void initView() {
        mLeftViewIndex = -1;
        mRightViewIndex = 0;
        mDisplayOffset = 0;
        mCurrentX = 0;
        mNextX = 0;
        mMaxX = Integer.MAX_VALUE;
        mScroller = new Scroller(getContext());
        mGesture = new GestureDetector(getContext(), mOnGesture);
    }
   
    @Override
    public void setOnItemSelectedListener(AdapterView.OnItemSelectedListener listener) {
        mOnItemSelected = listener;
    }
   
    @Override
    public void setOnItemClickListener(AdapterView.OnItemClickListener listener){
        mOnItemClicked = listener;
    }
   
    @Override
    public void setOnItemLongClickListener(AdapterView.OnItemLongClickListener listener) {
        mOnItemLongClicked = listener;
    }

    private DataSetObserver mDataObserver = new DataSetObserver() {

        @Override
        public void onChanged() {
            synchronized(HorizontalListView.this){
                mDataChanged = true;
            }
            invalidate();
            requestLayout();
        }

        @Override
        public void onInvalidated() {
            reset();
            invalidate();
            requestLayout();
        }
       
    };

    @Override
    public ListAdapter getAdapter() {
        return mAdapter;
    }

    @Override
    public View getSelectedView() {
        //TODO: implement
        return null;
    }

    @Override
    public void setAdapter(ListAdapter adapter) {
        if(mAdapter != null) {
            mAdapter.unregisterDataSetObserver(mDataObserver);
        }
        mAdapter = adapter;
        mAdapter.registerDataSetObserver(mDataObserver);
        reset();
    }
   
    private synchronized void reset(){
        initView();
        removeAllViewsInLayout();
        requestLayout();
    }

    @Override
    public void setSelection(int position) {
        //TODO: implement
    }
   
    private void addAndMeasureChild(final View child, int viewPos) {
        LayoutParams params = child.getLayoutParams();
        if(params == null) {
            params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        }

        addViewInLayout(child, viewPos, params, true);
        child.measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST),
                MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.AT_MOST));
    }
   
   

    @Override
    protected synchronized void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);

        if(mAdapter == null){
            return;
        }
       
        if(mDataChanged){
            int oldCurrentX = mCurrentX;
            initView();
            removeAllViewsInLayout();
            mNextX = oldCurrentX;
            mDataChanged = false;
        }

        if(mScroller.computeScrollOffset()){
            int scrollx = mScroller.getCurrX();
            mNextX = scrollx;
        }
       
        if(mNextX <= 0){
            mNextX = 0;
            mScroller.forceFinished(true);
        }
        if(mNextX >= mMaxX) {
            mNextX = mMaxX;
            mScroller.forceFinished(true);
        }
       
        int dx = mCurrentX - mNextX;
       
        removeNonVisibleItems(dx);
        fillList(dx);
        positionItems(dx);
       
        mCurrentX = mNextX;
       
        if(!mScroller.isFinished()){
            post(new Runnable(){
                @Override
                public void run() {
                    requestLayout();
                }
            });
           
        }
    }
   
    private void fillList(final int dx) {
        int edge = 0;
        View child = getChildAt(getChildCount()-1);
        if(child != null) {
            edge = child.getRight();
        }
        fillListRight(edge, dx);
       
        edge = 0;
        child = getChildAt(0);
        if(child != null) {
            edge = child.getLeft();
        }
        fillListLeft(edge, dx);
       
       
    }
   
    private void fillListRight(int rightEdge, final int dx) {
        while(rightEdge + dx < getWidth() && mRightViewIndex < mAdapter.getCount()) {
           
            View child = mAdapter.getView(mRightViewIndex, mRemovedViewQueue.poll(), this);
            addAndMeasureChild(child, -1);
            rightEdge += child.getMeasuredWidth();
           
            if(mRightViewIndex == mAdapter.getCount()-1) {
                mMaxX = mCurrentX + rightEdge - getWidth();
            }
           
            if (mMaxX < 0) {
                mMaxX = 0;
            }
            mRightViewIndex++;
        }
       
    }
   
    private void fillListLeft(int leftEdge, final int dx) {
        while(leftEdge + dx > 0 && mLeftViewIndex >= 0) {
            View child = mAdapter.getView(mLeftViewIndex, mRemovedViewQueue.poll(), this);
            addAndMeasureChild(child, 0);
            leftEdge -= child.getMeasuredWidth();
            mLeftViewIndex--;
            mDisplayOffset -= child.getMeasuredWidth();
        }
    }
   
    private void removeNonVisibleItems(final int dx) {
        View child = getChildAt(0);
        while(child != null && child.getRight() + dx <= 0) {
            mDisplayOffset += child.getMeasuredWidth();
            mRemovedViewQueue.offer(child);
            removeViewInLayout(child);
            mLeftViewIndex++;
            child = getChildAt(0);
           
        }
       
        child = getChildAt(getChildCount()-1);
        while(child != null && child.getLeft() + dx >= getWidth()) {
            mRemovedViewQueue.offer(child);
            removeViewInLayout(child);
            mRightViewIndex--;
            child = getChildAt(getChildCount()-1);
        }
    }
   
    private void positionItems(final int dx) {
        if(getChildCount() > 0){
            mDisplayOffset += dx;
            int left = mDisplayOffset;
            for(int i=0;i<getChildCount();i++){
                View child = getChildAt(i);
                int childWidth = child.getMeasuredWidth();
                child.layout(left, 0, left + childWidth, child.getMeasuredHeight());
                left += childWidth + child.getPaddingRight();
            }
        }
    }
   
    public synchronized void scrollTo(int x) {
        mScroller.startScroll(mNextX, 0, x - mNextX, 0);
        requestLayout();
    }
   
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        boolean handled = super.dispatchTouchEvent(ev);
        handled |= mGesture.onTouchEvent(ev);
        return handled;
    }
   
    protected boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                float velocityY) {
        synchronized(HorizontalListView.this){
            mScroller.fling(mNextX, 0, (int)-velocityX, 0, 0, mMaxX, 0, 0);
        }
        requestLayout();
       
        return true;
    }
   
    protected boolean onDown(MotionEvent e) {
        mScroller.forceFinished(true);
        return true;
    }
   
    private OnGestureListener mOnGesture = new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onDown(MotionEvent e) {
            return HorizontalListView.this.onDown(e);
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                float velocityY) {
            return HorizontalListView.this.onFling(e1, e2, velocityX, velocityY);
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2,
                float distanceX, float distanceY) {
           
            synchronized(HorizontalListView.this){
                mNextX += (int)distanceX;
            }
            requestLayout();
           
            return true;
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            for(int i=0;i<getChildCount();i++){
                View child = getChildAt(i);
                if (isEventWithinView(e, child)) {
                    if(mOnItemClicked != null){
                        mOnItemClicked.onItemClick(HorizontalListView.this, child, mLeftViewIndex + 1 + i, mAdapter.getItemId( mLeftViewIndex + 1 + i ));
                    }
                    if(mOnItemSelected != null){
                        mOnItemSelected.onItemSelected(HorizontalListView.this, child, mLeftViewIndex + 1 + i, mAdapter.getItemId( mLeftViewIndex + 1 + i ));
                    }
                    break;
                }
               
            }
            return true;
        }
       
        @Override
        public void onLongPress(MotionEvent e) {
            int childCount = getChildCount();
            for (int i = 0; i < childCount; i++) {
                View child = getChildAt(i);
                if (isEventWithinView(e, child)) {
                    if (mOnItemLongClicked != null) {
                        mOnItemLongClicked.onItemLongClick(HorizontalListView.this, child, mLeftViewIndex + 1 + i, mAdapter.getItemId(mLeftViewIndex + 1 + i));
                    }
                    break;
                }

            }
        }

        private boolean isEventWithinView(MotionEvent e, View child) {
            Rect viewRect = new Rect();
            int[] childPosition = new int[2];
            child.getLocationOnScreen(childPosition);
            int left = childPosition[0];
            int right = left + child.getWidth();
            int top = childPosition[1];
            int bottom = top + child.getHeight();
            viewRect.set(left, top, right, bottom);
            return viewRect.contains((int) e.getRawX(), (int) e.getRawY());
        }
    };
}



HorizontalListViewDemo.java

package com.sandy.demo;


import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

public class HorizontalListViewDemo extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
      
        setContentView(R.layout.listviewdemo);
      
        HorizontalListView listview = (HorizontalListView) findViewById(R.id.listview);
        listview.setAdapter(mAdapter);
      
    }
   
    private static String[] dataObjects = new String[]{ "Text #1",
        "Text #2",
        "Text #3","Text #4","Text #5","Text #6","Text #7","Text #8","Text #9","Text #10" };
   
    private BaseAdapter mAdapter = new BaseAdapter() {

        private OnClickListener mOnButtonClicked = new OnClickListener() {
          
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(HorizontalListViewDemo.this);
                builder.setMessage("hello from " + v);
                builder.setPositiveButton("Cool", null);
                builder.show();
              
            }
        };

        @Override
        public int getCount() {
            return dataObjects.length;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View retval = LayoutInflater.from(parent.getContext()).inflate(R.layout.viewitem, null);
            TextView title = (TextView) retval.findViewById(R.id.title);
            Button button = (Button) retval.findViewById(R.id.clickbutton);
            button.setOnClickListener(mOnButtonClicked);
            title.setText(dataObjects[position]);
          
            return retval;
        }
      
    };

}
 


main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
</LinearLayout>

 


listviewdemo.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="#fff"
  >
 
  <com.sandy.demo.HorizontalListView
      android:id="@+id/listview"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:background="#ddd"
  />
 
</LinearLayout>
 


viewitem.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:background="#fff"
  >
 
  <ImageView
      android:id="@+id/image"
      android:layout_width="150dip"
      android:layout_height="150dip"
      android:scaleType="centerCrop"
      android:src="@drawable/icon"
      />
    
      <TextView
      android:id="@+id/title"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textColor="#000"
      android:gravity="center_horizontal"
      />
    
      <Button
      android:id="@+id/clickbutton"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textColor="#000"
      android:text="Click Me"
      />
 
</LinearLayout>






Click here to Download.



 






61 comments:

  1. Thanks a lot. Lots of examples are there..but this is the most simple one and bug-free.

    ReplyDelete
  2. Welcome @Syamantak Basu. I put it all here because of everyone who required, they get easily demo and solve his/her problems.

    ReplyDelete
    Replies
    1. thank you so much

      Delete
    2. How to set load more for horizontal listview?

      Delete
    3. Thnxx... it's working very well :-)

      Delete
  3. How to give space between listview items.plz tell me

    ReplyDelete
    Replies
    1. you need to create viewitem.xml like your requirements.
      means you just put margin in that .xml file and get space between two listdata.

      Delete
  4. This is a plagiary!! You are a FRAUD and plagiarist because you copy it completely textually from https://github.com/dinocore1 and didn't give any credit. At least you should be creative and change the methods name.

    ReplyDelete
    Replies
    1. Maybe so. I saw the GitHub version first but because I couldn't load it into my Android Studio, I found this simple listing easier to handle. It's good either way. Thanks sandip.

      Delete
  5. Hi, I would like to suggest you to put image like that we can have an view of how it is displaying

    ReplyDelete
    Replies
    1. Thanks for Suggestion, I do it ASAP...

      Delete
    2. How i do set load more item with horizontal gridview?

      Delete
  6. sandip, i'm getting error...

    12-18 05:45:44.007: E/AndroidRuntime(1324): FATAL EXCEPTION: main
    12-18 05:45:44.007: E/AndroidRuntime(1324): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.hlv/com.example.hlv.HorizontalListView}: java.lang.InstantiationException: can't instantiate class com.example.hlv.HorizontalListView; no empty constructor
    12-18 05:45:44.007: E/AndroidRuntime(1324): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at android.app.ActivityThread.access$600(ActivityThread.java:141)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at android.os.Handler.dispatchMessage(Handler.java:99)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at android.os.Looper.loop(Looper.java:137)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at android.app.ActivityThread.main(ActivityThread.java:5103)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at java.lang.reflect.Method.invokeNative(Native Method)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at java.lang.reflect.Method.invoke(Method.java:525)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at dalvik.system.NativeStart.main(Native Method)
    12-18 05:45:44.007: E/AndroidRuntime(1324): Caused by: java.lang.InstantiationException: can't instantiate class com.example.hlv.HorizontalListView; no empty constructor
    12-18 05:45:44.007: E/AndroidRuntime(1324): at java.lang.Class.newInstanceImpl(Native Method)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at java.lang.Class.newInstance(Class.java:1130)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
    12-18 05:45:44.007: E/AndroidRuntime(1324): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
    12-18 05:45:44.007: E/AndroidRuntime(1324): ... 11 more

    ReplyDelete
    Replies
    1. you need to create constructor of HorizontalListView class.

      because in your error code tell me that.
      12-18 05:45:44.007: E/AndroidRuntime(1324): Caused by: java.lang.InstantiationException: can't instantiate class com.example.hlv.HorizontalListView; no empty constructor

      so, please create one empty constructor first.

      Delete
  7. Hi ,
    this horizontal list view scrolling is not as smooth as it happens in Gallery or list view. please tell me how we can scroll smoothly .

    ReplyDelete
  8. when i put in inside scroll view it didn't appear why ?!!

    ReplyDelete
    Replies
    1. Because Scroll View is a one Control and It also contain the scroll property like this one. so, no need to use Scroll View as parent of this view.

      Delete
  9. Dude, you forgot to mention that the original implementation is from dev-smart.
    Link is here: http://www.dev-smart.com/archives/34

    ReplyDelete
    Replies
    1. Yes, I think you has to link to original post and author.

      Delete
  10. how can i load more item in listview when i scroll to right of listview , you listview does't have onscroll listener

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. I already put in HorizontalListView class.

      @Override
      public boolean onScroll(MotionEvent e1, MotionEvent e2,
      float distanceX, float distanceY) {

      synchronized(HorizontalListView.this){
      mNextX += (int)distanceX;
      }
      requestLayout();

      return true;
      }

      Delete
    3. i want to add footer at the end of horizontallistview...pls tell how can i do it?

      Delete
    4. how do use onScroll in activity?

      Delete
  11. Hi,How can I implement auto scroll in the above code

    ReplyDelete
  12. Ho to set the gravity of this Horizontal listview as center of it's parent.

    ReplyDelete
  13. HorizontalListView layout_height="wrap_content" does not work..

    ReplyDelete
  14. Thanks alot for lovely tutorial , how to set list in bottom instead of top , i set the layout gravity in bottom but does not work??
    please help me ?

    ReplyDelete
    Replies
    1. YOu need to use RelativeLayout instead of LinearLayout in "listviewdemo.xml"
      file. and then put "android:layout_alignParentBottom="true" in "com.sandy.demo.HorizontalListView" control.

      like below.

      listviewdemo.xml






      Delete
    2. I don't want to change the position of images when it scrolls then tell me the portion of code to remove on it.

      Delete
  15. Thanks for tutorial. but i have some problems. i have so much item row in list adapter , when i'm trying this horizontal LV , item rows (2nd,3rd, etc) always added in first row. Any help ? Thank you very much....

    ReplyDelete
  16. @jigar jimsky Same problem......

    ReplyDelete
  17. 12-05 03:38:04.203: E/AndroidRuntime(20165): FATAL EXCEPTION: main
    12-05 03:38:04.203: E/AndroidRuntime(20165): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.horizontaldemo/com.example.horizontaldemo.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.horizontaldemo.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.horizontaldemo-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.horizontaldemo-1, /system/lib]]
    12-05 03:38:04.203: E/AndroidRuntime(20165): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at android.app.ActivityThread.access$600(ActivityThread.java:141)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at android.os.Handler.dispatchMessage(Handler.java:99)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at android.os.Looper.loop(Looper.java:137)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at android.app.ActivityThread.main(ActivityThread.java:5103)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at java.lang.reflect.Method.invokeNative(Native Method)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at java.lang.reflect.Method.invoke(Method.java:525)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at dalvik.system.NativeStart.main(Native Method)
    12-05 03:38:04.203: E/AndroidRuntime(20165): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.horizontaldemo.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.horizontaldemo-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.horizontaldemo-1, /system/lib]]
    12-05 03:38:04.203: E/AndroidRuntime(20165): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
    12-05 03:38:04.203: E/AndroidRuntime(20165): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
    12-05 03:38:04.203: E/AndroidRuntime(20165): ... 11 more

    ReplyDelete
  18. hey! how does this work in RTL?

    ReplyDelete
  19. How to limit gesture for list only..not for complete page

    ReplyDelete
  20. It was really nice and cool tut. thanks and keep it up!! Thumbs Up!!

    ReplyDelete
  21. how to put side arrows in horizontal list view???

    ReplyDelete
  22. Hi,

    Can you please let me know how to implement the setSelection Method?, if you have code for that can you please share that as well

    ReplyDelete
  23. Hi,
    can you please implement the smoothScrollto and setSelection Methods.

    ReplyDelete
  24. Hi, I appreciate your work it helped me a lot

    ReplyDelete
  25. How can get item value of the dataobjects when the button is clicked

    ReplyDelete
  26. when i am scrolling listview the item get selected even if i do not want..i have used my own baseadapter and didnot used onclicklistener that is there in your base adapter

    ReplyDelete
  27. HorizontialListView how to work in android studio

    please compile lib please

    ReplyDelete
  28. I have to use a horizontal listview containing Images of a song playing below that horizontal listview in a Vertical listview conatining songs.. both are scrolling smoothly, How can I do that ?

    ReplyDelete
  29. i am not able to download example..

    ReplyDelete
  30. how to scroll listview automaticaly continue

    ReplyDelete
  31. Horizontally list images and bind text using recyclerView. Check this tutorial... http://whats-online.info/science-and-tutorials/87/Android-tutorial-Horizontal-RecyclerView-with-images-and-text-example/

    ReplyDelete
  32. Hello sandip. Thanks for this. It may well have had it origins elsewhere but your listing is the one that got me productively started on a problem I have had for some while. That was for a double row horizontal list view to place in the vertical centre of a protract screen on a Android. I managed to add the second row with little or no trouble and have added item locaters that place the desired item (eg the selected item) in the centre of the screen. Adjusting the size of my list presented to the horizontal list view proved to be trickier. In the end, I had to create a completely new Horizontal List View and make a few kludges in the onLayout(...) of the ViewGroup that holds the Horizontal List View. But, did I miss an easier way to resize my list and synchronize the Horizontal List View?

    ReplyDelete
  33. Oh no no no no. My last didn't work. I just ran out memory. So my question is how do I reset my HorizontalListView to a supplied array of different length and varied data in. The array is just and ArrayList with different selections from the same basic source. This is built into BaseAsapter mAdapater via its overrides getView and getCount. When I change the array contents, I issue a HorizontalListView instance.refresh(mApapter) call. I added refresh to the HorizontalListView class as
    public synchronized void refresh(BaseAdapter baseAdapter) {
    mScroller.forceFinished(true);
    mDataChanged = true;
    baseAdapter.notifyDataSetInvalidated();
    }
    This successfully makes the HorizontalListView display the new array correctly BUT the scroller and fling don't work. It appears its control variables are totally out of sync!! How do I remedy this.

    ReplyDelete
  34. Best content & valuable as well. Thanks for sharing this content.
    Approved Auditor in DAFZA
    Approved Auditor in RAKEZ
    Approved Auditor in JAFZA
    i heard about this blog & get actually whatever i was finding. Nice post love to read this blog
    Approved Auditor in DMCC

    ReplyDelete
  35. I feel astoundingly reeled to have https://playboyclothing.net/ seen your post. I thought about the most surprising and dazzling one. I'm incredibly happy to visit your post.

    ReplyDelete
  36. Nice blog Juice Wrld Merch and absolutely outstanding. You can do something much better but i still say this perfect. Keep trying for the best.

    ReplyDelete
  37. Most of us know how to manage our finances using a smartphone app, however, some of us may find it challenging to use an extension. This misconception that using the extension is difficult will be dispelled in this section of the post as we go over how to download and install the MetaMask browser extension.
    If you are signing up for Informed delivery, a free and optional notification feature is provided by the Zelle login account. It allows you to digitally preview your letter and manage incoming packages all on the dashboard, here are the steps that you need to follow steps for zelle login

    ReplyDelete
  38. "Wow! This blog is a mind-expanding kanyewestmerch adventure! 🚀 Fascinating insights presented with crystal-clear clarity.🌟 I'm hooked and can't wait for the next knowledge boost! 💡📚"

    ReplyDelete
  39. Très content de mon achat Corteiz. Le pull est agréable, bien taillé, et super stylé. Idéal pour l’hiver, il tient bien chaud. Un classique moderne.

    ReplyDelete

Animation Tutorial

Animation Image Used in Android Tutorial GIF Image used in Android Application. for that you need to use following code implementation...