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 8758653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:36:13+00:00 2026-06-13T14:36:13+00:00

I have ListView with several elements of type LinearLayout. How to make slide effect

  • 0

I have ListView with several elements of type LinearLayout. How to make slide effect on they like as in the contacts(when a contact slide on the right then there is a call, in the other case message is written).

  • 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-13T14:36:14+00:00Added an answer on June 13, 2026 at 2:36 pm

    That is view pager that your talking about
    Here is an example that i have made for you

    The ViewPageExample.java file

    public class ViewPageExample extends Activity {
    
    private ViewPager mViewPager;
    private Context mContext;
    private MyPageAdatper mAdapter;
    
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mContext = this;
    
    mAdapter = new MyPageAdatper();
    mViewPager = (ViewPager) findViewById(R.id.mViewPager);
    mViewPager.setAdapter(mAdapter);
    }
    
    private class MyPageAdatper extends PagerAdapter{
    
    
            @Override
            public int getCount() {
                   //Since only contacts messages and call logs were mentioned by you
                    return 3;
            }
    
    
            @Override
            public Object instantiateItem(View collection, int position) {
                LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View mView = null ;
                switch(position){
                    case 0:
                        mView   =   inflater.inflate(R.layout.contacts, null);  
                        Button btn1 = (Button) mView.findViewById(R.id.button1);
                        btn1.setOnClickListener(new OnClickListener() {
    
                            @Override
                            public void onClick(View v) {
                                Toast.makeText(getApplicationContext(), "Clicked", Toast.LENGTH_SHORT).show();
                            }
                        });
                    break;
    
                    case 1:
                        mView   =   inflater.inflate(R.layout.messages, null);   
                    break;
    
                    case 2:
                        mView   =   inflater.inflate(R.layout.callogs, null);   
                    break;
                }
    
    
    
    
                    ((ViewPager) collection).addView(mView,0);
    
                    return mView;
            }
    
    
            @Override
            public void destroyItem(View collection, int position, Object view) {
                    ((ViewPager) collection).removeView((View) view);
            }
    
    
    
            @Override
            public boolean isViewFromObject(View view, Object object) {
                    return view==((View)object);
            }
    
    
            @Override
            public void finishUpdate(View arg0) {}
    
    
            @Override
            public void restoreState(Parcelable arg0, ClassLoader arg1) {}
    
            @Override
            public Parcelable saveState() {
                    return null;
            }
    
            @Override
            public void startUpdate(View arg0) {}
    
    }
    
    
    }
    

    The activity_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"
    android:background="#a4c639">
    <android.support.v4.view.ViewPager
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/mViewPager"/>
    </LinearLayout>
    

    The callogs.xml

    <?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" >
    
    
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Call Logs"
        android:textAppearance="?android:attr/textAppearanceLarge" />
    </LinearLayout>
    

    The contacts.xml

    <?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" >
    
    
    
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Contacts"
        android:textAppearance="?android:attr/textAppearanceLarge" />
    
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />
    
    </LinearLayout>
    

    The messages.xml

    <?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" >
    
    
    
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="SomeMessages"
        android:textAppearance="?android:attr/textAppearanceLarge" />
    
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView template that's being used in several places and I'd like
I have a LinearLayout view that already contains several elements. I want to add
I have a listview and i would like to populate a row with several
I have a listview with several items that are created dynamically, each has two
I have a listview that contain several EditTexts created dynamically according to the number
I have ListView that uses a GridView to display several columns of data. Two
Background: I have a ListView / GridView with several columns. In some situations, only
I have several listviews with two collumns like. I am building a stats application
I have a ListView with several columns. How can I access the index of
Say I have a listview control with several items in it. How would I

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.