Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9083379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:45:38+00:00 2026-06-16T20:45:38+00:00

I have list on android. Each time user slide screen left or right I

  • 0

I have list on android. Each time user slide screen left or right I need to show them single item with details. Which method should I use for this situation.

Example screenshots:
First Item

first item http://imageshack.us/a/img707/9789/slide1t.png

Second Item appears when user slide to left

first item http://imageshack.us/a/img163/7351/slide2nl.png

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:45:39+00:00Added an answer on June 16, 2026 at 8:45 pm

    I found simple solution for my question. ViewSwitcher with OnGestureListener solves my problem.

    http://www.youtube.com/watch?v=mGwG8-chUEM

    References:

    ViewFlipper: http://developer.android.com/reference/android/widget/ViewFlipper.html

    ViewSwitcher: http://developer.android.com/reference/android/widget/ViewSwitcher.html

    GestureDetector.OnGestureListener: http://developer.android.com/reference/android/view/GestureDetector.OnGestureListener.html

    Source Code:
    http://www.mediafire.com/?fg32sn1345xn5dl

    My activity doesn’t have all code, so maybe it may not work. But logic is here.

    ——-My solution——–

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <ViewSwitcher
            android:id="@+id/viewSwitcher"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1" >
    
            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="#65ffffff" >
    
                <TextView
                    android:id="@+id/txtHeader"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:text="0" />
    
                <TextView
                    android:id="@+id/txtDetail"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/txtKurum"
                    android:layout_centerHorizontal="true"
                    android:text="0" />
            </RelativeLayout>
        </ViewSwitcher>
    
    </LinearLayout>
    

    -Activity-

    public class MyActivity extends Activity implements OnClickListener,
            OnGestureListener {
    
        ArrayList<String> liste;
    
        TextView txtHeader;
        TextView txtDetail;
    
        private ViewSwitcher switcher;
    
        int bakiyeCounter = 0;
        private GestureDetector gesturedetector = null;
    
        int SWIPE_MIN_VELOCITY = 100;
        int SWIPE_MIN_DISTANCE = 100;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.bakiye);
            switcher = (ViewSwitcher) findViewById(R.id.viewSwitcher);
            txtHeader = (TextView) findViewById(R.id.txtHeader);
            txtDetail = (TextView) findViewById(R.id.txtDetail);
            gesturedetector = new GestureDetector(this, this);
        }
    
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                float velocityY) {
            // Get Position
            float ev1X = e1.getX();
            float ev2X = e2.getX();
    
            // Get distance of X (e1) to X (e2)
            final float xdistance = Math.abs(ev1X - ev2X);
    
            final float xvelocity = Math.abs(velocityX);
    
            if ((xvelocity > SWIPE_MIN_VELOCITY)
                    && (xdistance > SWIPE_MIN_DISTANCE)) {
                if (ev1X > ev2X)// Switch Left
                {
                    if (bakiyeCounter < liste.size() - 1) {
                        bakiyeCounter++;
                        previousView();
                    }
                } else// Switch Right
                {
                    if (bakiyeCounter > 0) {
                        bakiyeCounter--;
                        nextView();
                    }
                }
            }
    
            return false;
        }
    
        private void previousView() {
    
    
            txtHeader.setText(liste.get(bakiyeCounter).getHeader());
            txtDetail.setText(liste.get(bakiyeCounter).getDetail());
            switcher.showPrevious();
    
        }
    
        private void nextView() {
    
            txtDetail.setText(liste.get(bakiyeCounter).getHeader());
            txtHeader.setText(liste.get(bakiyeCounter).getDetail());
            switcher.showNext();
    
        }
    
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            return gesturedetector.onTouchEvent(event);
        }
    
        @Override
        public boolean onDown(MotionEvent e) {
            // TODO Auto-generated method stub
            return false;
        }
    
        @Override
        public void onLongPress(MotionEvent e) {
            // TODO Auto-generated method stub
    
        }
    
        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
                float distanceY) {
            // TODO Auto-generated method stub
            return false;
        }
    
        @Override
        public void onShowPress(MotionEvent e) {
            // TODO Auto-generated method stub
    
        }
    
        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            // TODO Auto-generated method stub
            return false;
        }
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
    
    }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android activity with a list. Each item can be clicked and
I have two panes(left side list and right side details) in my android tablet
I'm using Android-support-v4 I have a PagerAdapter that displays a list fragment in each
I have a task list, and have defined each list item in list_item.xml as
I have a listview : <ListView android:clickable=true android:id=@android:id/list android:layout_width=match_parent android:layout_height=wrap_content > </ListView> the elements
I have created an ExpandableListView with the following code: <ExpandableListView android:id=@+id/android:list android:layout_width=wrap_content android:layout_height=0dp android:layout_marginTop=5dp
In my XML, I have the following <ListView android:id=@android:id/list android:layout_width=match_parent android:layout_height=fill_parent > </ListView> How
I'm developing an Android application. On one activity I have a List with list
i have recently developed a list program in android in which there is an
It seems that android has enforced that a listview must have the name android:id=@android:id/list,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.