Android Swipe View with Tab layout – Example

You may also like...

  • Karthik Ramesh

    above code can you make it extends ListFragment

    • http://128.199.224.11/ Raj Amal

      yes

      • Danny Moses

        Thanks for this. I been trying to learn android and java little by little trying to create an app. This example is awesome. I want to add a list of text to each page and change the page titles to match the contents but I’m stuck. Can you post an example of an array of text.

  • Ľuboš Mudrák

    I wonder. Is there way how to prevent constant calling of constructor of each fragments while swipping ? Only create them once and call that instance ?

  • Sylvina

    Hi, i’m working on tabsswipe project right now. But, i still don’t know how to put an expendables list view inside of my specific tab, or a button inside the tab which can go to other activity after i’ve clicked . Can you help me please?

    • http://128.199.224.11/ Raj Amal

      It is similar to normal expendable listview, but you need to implement it in a fragment.

  • Cdn

    Hi there and thanks for this tutorial, do you know if it is possible to compile your project, so as to generate an.apk, without going through an IDE like Eclipse ?

  • tgrclw

    How to Theme.NoTitleBar?

    • http://128.199.224.11/ Raj Amal

      Add this to your styles.xml file

  • Bek

    Hi Raj!
    How to start certain tab from another activity using simple button in your project? for example, to start with second tab.

  • Masha

    Heey. Great Tutorial. I have a gridview with images, when i click on one i use an adapter to pop it out onto an entire activity for viewing (like if i was to choose one). How do i swipe through the ‘popped out’ images?

  • Alex

    I need to make an activity with swipe tabs on a new window after I choose it on the menu. Can i use this code but change the names of activities and layouts?

  • Kaos1337

    There is a bug, at the launch if you log (Log.i(…)) the switch case of the tab adapter you will see that it will go from case 0 to 1 doing nothing.

  • caspecor

    how to insert this code in android tab for example?

    ////////////////////////////////////////////////////

    package com.example.multitouch;

    import java.util.ArrayList;

    import android.os.Bundle;

    import android.app.Activity;

    import android.util.Log;

    import android.view.View;

    import android.view.Window;

    import android.view.WindowManager;

    import android.widget.AdapterView;

    import android.widget.AdapterView.OnItemClickListener;

    import android.widget.ListView;

    import android.widget.Toast;

    public class CajaActivity extends Activity {

    ListView userList;

    UserCustomAdapter userAdapter;

    ArrayList userArray = new ArrayList();

    @Override

    protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_caja);

    /*

    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_login);

    */

    /**

    * add item in arraylist

    */

    userArray.add(new Mesa(“Mesa 1″, “Total:”, “45.36 €”));

    userArray.add(new Mesa(“Mesa 2″, “Total:”, “22.68 €”));

    userArray.add(new Mesa(“Mesa 3″, “Total:”, “98.44 €”));

    userArray.add(new Mesa(“Mesa 4″, “Total:”, “12.14 €”));

    userArray.add(new Mesa(“Mesa 5″, “Total:”, “45.75 €”));

    userArray.add(new Mesa(“Mesa 6″, “Total:”, “56.85 €”));

    userArray.add(new Mesa(“Mesa 7″, “Total:”, “55.69 €”));

    /**

    * set item into adapter

    */

    userAdapter = new UserCustomAdapter(CajaActivity.this, R.layout.row,

    userArray);

    userList = (ListView) findViewById(R.id.listView);

    userList.setItemsCanFocus(false);

    userList.setAdapter(userAdapter);

    /**

    * get on item click listener

    */

    userList.setOnItemClickListener(new OnItemClickListener() {

    @Override

    public void onItemClick(AdapterView parent, View v,

    final int position, long id) {

    Log.i(“List View Clickeado”, “**********”);

    Toast.makeText(CajaActivity.this,

    “List View Clickeado:” + position, Toast.LENGTH_LONG)

    .show();

    }

    });

    }

    }

    //////////////////////////////////

  • Mohamed

    thank you.

  • Vikas

    Hi Raj
    Can you let me know how to display list of data where you are displaying Windows/IOS/Android

    • http://www.learn2crack.com/ Raj Amal

      You can display list by extending the class to ListFragment.

      • Vikas

        Could you please add some example in your code.

  • Francesco

    Very helpful! Thank you very much!