Skip to content Skip to sidebar Skip to footer

Displaying Horizontal Scrolling View Of A Linear Layout.

I would like to create a horizontally scrolling view of an image with text description and a button. Each entry in the list will take up the entire screen with a picture on the le

Solution 1:

You may need to check out the ViewFlipper of android.

Solution 2:

I think you are in search of listview which can be explored horizontally rather than vertically.

so you can take a look at horizontal listview code of course you can use gallery for this type of view.... Hope this may help you... Have a Happy coding.

Solution 3:

OK, here is a way to implement what I was looking to do. I initially took this from http://geekyouup.blogspot.com/2011/07/viewpager-example-from-paug.html but I wanted to add more than one textView to the scrolling list.

I was struggling at first to include more than the one text view which is shown in the demo at this site but it was because of then Casting to TextView in the destroyItem and initemfromObject methods. I'm going to be writing a PagerCurrsor adapter for sqlite so I'll post it here when I get it working.

Another thing to note is that position is incremented as the user swipes through the list so you would use that to iterate through an array or a cursor.

Hope this helps other developers and thanks for all the answers posted.

Overidden methods:

publicObjectinstantiateItem(View collection, int position) {

            layout = inflater.inflate(R.layout.scrolllayout, null);
            TextView tv = (TextView) layout.findViewById(R.id.textView1);
            tv.setText("1________________>" + position);

            TextView tv2 = (TextView) layout.findViewById(R.id.textView2);
            tv.setText("2________________>" + position);

            ((ViewPager) collection).addView(layout);
            return layout;
        }


            @OverridepublicvoiddestroyItem(View collection, int position, Object view) {
                    ((ViewPager) collection).removeView((View)view);
            }



            @OverridepublicbooleanisViewFromObject(View view, Objectobject) {


               return view==((View)object);
            }

XML:

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id= "@+id/container"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="TextView1"android:id="@+id/textView1"></TextView><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="TextView2"android:id="@+id/textView2"></TextView></LinearLayout>

[1]http://geekyouup.blogspot.com/2011/07/viewpager-example-from-paug.html

Post a Comment for "Displaying Horizontal Scrolling View Of A Linear Layout."