Thursday, 27 October 2016

Android Spinner Example.

Android Spinner Example
Spinnertable


SpinnerPHP.php
<?php
$DB_USER='u532517283_user';
$DB_PASS='**********';
$DB_HOST='mysql.hostinger.in';
$DB_NAME='u532517283_bdm';
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}                              

$mysqli->query("SET NAMES 'utf8'");
$sql="SELECT iname FROM tblinterviewees";
$result=$mysqli->query($sql);
while($e=mysqli_fetch_assoc($result)){
$output[]=$e;
}              

print(json_encode($output));
$mysqli->close();   
?>

AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />

Bulid.gradle
compile 'com.loopj.android:android-async-http:1.4.5'

compile files("${android.getSdkDirectory().getAbsolutePath()}" +
 File.separator + "platforms" + File.separator + "android-23" + 
File.separator + "optional" + File.separator + "org.apache.http.legacy.jar")

activity_mail.xml
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:paddingBottom="@dimen/activity_vertical_margin"

    android:paddingLeft="@dimen/activity_horizontal_margin"

    android:paddingRight="@dimen/activity_horizontal_margin"

    android:paddingTop="@dimen/activity_vertical_margin"

    tools:context="com.example.mihir.myspinnerexample.MainActivity">



    <Spinner

        android:id="@+id/spinner"

        android:layout_width="match_parent"

        android:layout_height="wrap_content">

    </Spinner>



</RelativeLayout>
 
Spinner_layput.xml
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:orientation="vertical" android:layout_width="match_parent"

    android:layout_height="match_parent">

    <TextView

        android:id="@+id/txt"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:padding="10dp"

        />

</LinearLayout>

MainActivity.java
package com.example.mihir.myspinnerexample;



import android.os.AsyncTask;

import android.support.v7.app.ActionBarActivity;

import android.os.Bundle;

import android.widget.ArrayAdapter;

import android.widget.Spinner;

import org.apache.http.HttpEntity;

import org.apache.http.HttpResponse;

import org.apache.http.client.HttpClient;

import org.apache.http.client.methods.HttpPost;

import org.apache.http.impl.client.DefaultHttpClient;

import org.json.JSONArray;

import org.json.JSONException;

import org.json.JSONObject;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.util.ArrayList;



public class MainActivity extends ActionBarActivity {

    ArrayList<String> listItems=new ArrayList<>();

    ArrayAdapter<String> adapter;

    Spinner sp;

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        sp=(Spinner)findViewById(R.id.spinner);

        adapter=new ArrayAdapter<String>(this,R.layout.spinner_layout,R.id.txt,listItems);

        sp.setAdapter(adapter);



    }

    public void onStart(){

        super.onStart();

        BackTask bt=new BackTask();

        bt.execute();

    }

    private class BackTask extends AsyncTask<Void,Void,Void> {

        ArrayList<String> list;

        protected void onPreExecute(){

            super.onPreExecute();

            list=new ArrayList<>();

        }

        protected Void doInBackground(Void...params){

            InputStream is=null;

            String result="";

            try{

                HttpClient httpclient=new DefaultHttpClient();

                HttpPost httppost= new HttpPost("http://compliments.esy.es/SpinnerPHP.php");

                HttpResponse response=httpclient.execute(httppost);

                HttpEntity entity = response.getEntity();

                // Get our response as a String.

                is = entity.getContent();

            }catch(IOException e){

                e.printStackTrace();

            }

            //convert response to string

            try{

                BufferedReader reader = new BufferedReader(new InputStreamReader(is,"utf-8"));

                String line = null;

                while ((line = reader.readLine()) != null) {

                    result+=line;

                }

                is.close();

                //result=sb.toString();

            }catch(Exception e){

                e.printStackTrace();

            }

            // parse json data

            try{

                JSONArray jArray =new JSONArray(result);

                for(int i=0;i<jArray.length();i++){

                    JSONObject jsonObject=jArray.getJSONObject(i);

                    // add interviewee name to arraylist

                    list.add(jsonObject.getString("iname"));

                }

            }

            catch(JSONException e){

                e.printStackTrace();

            }

            return null;

        }

        protected void onPostExecute(Void result){

            listItems.addAll(list);

            adapter.notifyDataSetChanged();

        }

    }

}


OutPut:

 

Wednesday, 26 October 2016

Android Fragment Tab Layout Example.

Android Fragment Tab Layout Example.

-Use the following code in your android project.

Styles.xml
<resources>

   
<!-- Base application theme. -->
   
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">

    </
style>

    <
style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
        <
item name="windowNoTitle">true</item>
        <
item name="windowActionBar">false</item>
        <
item name="colorPrimary">@color/colorPrimary</item>
        <
item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <
item name="colorAccent">@color/colorAccent</item>
    </
style>

    <
style name="MyMaterialTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <
style name="MyMaterialTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</
resources>

Colors.xml
<?xml version="1.0" encoding="utf-8"?>

<resources>

    <color name="colorPrimary">#125688</color>

    <color name="colorPrimaryDark">#125688</color>

    <color name="textColorPrimary">#FFFFFF</color>

    <color name="windowBackground">#FFFFFF</color>

    <color name="navigationBarColor">#000000</color>

    <color name="colorAccent">#c8e8ff</color>

</resources>

Build.gradle
apply plugin: 'com.android.application'

android {

    compileSdkVersion 24

    buildToolsVersion "24.0.2"

    defaultConfig {

        applicationId "com.devilsparadise9.mihir.fragmenttabexample"

        minSdkVersion 15

        targetSdkVersion 24

        versionCode 1

        versionName "1.0"

    }

    buildTypes {

        release {

            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }

    }

}


dependencies {

    compile fileTree(include: ['*.jar'], dir: 'libs')

    testCompile 'junit:junit:4.12'

    compile 'com.android.support:appcompat-v7:24.2.1'

    compile 'com.android.support:design:24.2.1'

    compile 'com.android.support:support-v4:24.2.1'

}

MainActivity.java
package com.devilsparadise9.mihir.fragmenttabexample;



import android.os.Bundle;

import android.support.design.widget.TabLayout;

import android.support.v4.app.Fragment;

import android.support.v4.app.FragmentManager;

import android.support.v4.app.FragmentPagerAdapter;

import android.support.v4.view.ViewPager;

import android.support.v7.app.AppCompatActivity;

import android.support.v7.widget.Toolbar;

import java.util.ArrayList;

import java.util.List;



public class MainActivity extends AppCompatActivity {



    private Toolbar toolbar;

    private TabLayout tabLayout;

    private ViewPager viewPager;

    //for icon in tab

    /*private int[] tabIcons = {

            R.mipmap.ic_launcher,

            R.mipmap.ic_launcher,

            R.mipmap.ic_launcher

    };*/



    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);



        toolbar = (Toolbar) findViewById(R.id.toolbar);

        setSupportActionBar(toolbar);

        getSupportActionBar().setDisplayHomeAsUpEnabled(false);



        viewPager = (ViewPager) findViewById(R.id.viewpager);

        setupViewPager(viewPager);



        tabLayout = (TabLayout) findViewById(R.id.tabs);

        tabLayout.setupWithViewPager(viewPager);

        //for tab icons

        /*setupTabIcons();*/

    }



    //for tab icons

    /*private void setupTabIcons() {



        tabLayout.getTabAt(0).setIcon(tabIcons[0]);

        tabLayout.getTabAt(1).setIcon(tabIcons[1]);

        tabLayout.getTabAt(2).setIcon(tabIcons[2]);

    }*/



    private void setupViewPager(ViewPager viewPager) {

        ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());

        adapter.addFrag(new OneFragment(), "ONE");

        adapter.addFrag(new TwoFragment(), "TWO");

        adapter.addFrag(new ThreeFragment(), "THREE");

        viewPager.setAdapter(adapter);

    }



    class ViewPagerAdapter extends FragmentPagerAdapter {

        private final List<Fragment> mFragmentList = new ArrayList<>();

        private final List<String> mFragmentTitleList = new ArrayList<>();



        public ViewPagerAdapter(FragmentManager manager) {

            super(manager);

        }



        @Override

        public Fragment getItem(int position) {

            return mFragmentList.get(position);

        }



        @Override

        public int getCount() {

            return mFragmentList.size();

        }



        public void addFrag(Fragment fragment, String title) {

            mFragmentList.add(fragment);

            mFragmentTitleList.add(title);

        }



        @Override

        public CharSequence getPageTitle(int position) {

            return mFragmentTitleList.get(position);

        }

    }

}

activity_main.xml
<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    android:layout_width="match_parent"

    android:layout_height="match_parent">



    <android.support.design.widget.AppBarLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">



        <android.support.v7.widget.Toolbar

            android:id="@+id/toolbar"

            android:layout_width="match_parent"

            android:layout_height="?attr/actionBarSize"

            android:background="?attr/colorPrimary"

            app:layout_scrollFlags="scroll|enterAlways"

            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />



        <android.support.design.widget.TabLayout

            android:id="@+id/tabs"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            app:tabMode="fixed"

            app:tabGravity="fill"/>

    </android.support.design.widget.AppBarLayout>



    <android.support.v4.view.ViewPager

        android:id="@+id/viewpager"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        app:layout_behavior="@string/appbar_scrolling_view_behavior"  />

</android.support.design.widget.CoordinatorLayout>

New Fragment Activity


OneFragment.java
package com.devilsparadise9.mihir.fragmenttabexample;



import android.net.Uri;

import android.os.Bundle;

import android.support.v4.app.Fragment;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;



/**

 * A simple {@link Fragment} subclass.

 * Activities that contain this fragment must implement the

 * {@link OneFragment.OnFragmentInteractionListener} interface

 * to handle interaction events.

 * Use the {@link OneFragment#newInstance} factory method to

 * create an instance of this fragment.

 */

public class OneFragment extends Fragment {

    // TODO: Rename parameter arguments, choose names that match

    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER

    private static final String ARG_PARAM1 = "param1";

    private static final String ARG_PARAM2 = "param2";



    // TODO: Rename and change types of parameters

    private String mParam1;

    private String mParam2;



    private OnFragmentInteractionListener mListener;



    public OneFragment() {

        // Required empty public constructor

    }



    /**

     * Use this factory method to create a new instance of

     * this fragment using the provided parameters.

     *

     * @param param1 Parameter 1.

     * @param param2 Parameter 2.

     * @return A new instance of fragment OneFragment.

     */

    // TODO: Rename and change types and number of parameters

    public static OneFragment newInstance(String param1, String param2) {

        OneFragment fragment = new OneFragment();

        Bundle args = new Bundle();

        args.putString(ARG_PARAM1, param1);

        args.putString(ARG_PARAM2, param2);

        fragment.setArguments(args);

        return fragment;

    }



    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        if (getArguments() != null) {

            mParam1 = getArguments().getString(ARG_PARAM1);

            mParam2 = getArguments().getString(ARG_PARAM2);

        }

    }



    @Override

    public View onCreateView(LayoutInflater inflater, ViewGroup container,

                             Bundle savedInstanceState) {

        // Inflate the layout for this fragment

        return inflater.inflate(R.layout.fragment_one, container, false);

    }



    // TODO: Rename method, update argument and hook method into UI event

    public void onButtonPressed(Uri uri) {

        if (mListener != null) {

            mListener.onFragmentInteraction(uri);

        }

    }



    /*@Override

    public void onAttach(Context context) {

        super.onAttach(context);

        if (context instanceof OnFragmentInteractionListener) {

            mListener = (OnFragmentInteractionListener) context;

        } else {

            throw new RuntimeException(context.toString()

                    + " must implement OnFragmentInteractionListener");

        }

    }*/



    @Override

    public void onDetach() {

        super.onDetach();

        mListener = null;

    }



    /**

     * This interface must be implemented by activities that contain this

     * fragment to allow an interaction in this fragment to be communicated

     * to the activity and potentially other fragments contained in that

     * activity.

     * <p/>

     * See the Android Training lesson <a href=

     * "http://developer.android.com/training/basics/fragments/communicating.html"

     * >Communicating with Other Fragments</a> for more information.

     */

    public interface OnFragmentInteractionListener {

        // TODO: Update argument type and name

        void onFragmentInteraction(Uri uri);

    }

}

fragment_one.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context="com.devilsparadise9.mihir.fragmenttabexample.OneFragment">



    <!-- TODO: Update blank fragment layout -->

    <TextView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="Fragment ONE"

        android:layout_gravity="center"

        android:typeface="serif"

        android:textStyle="bold"

        android:textSize="30dp" />



</FrameLayout>

TwoFragment.java
package com.devilsparadise9.mihir.fragmenttabexample;



import android.net.Uri;

import android.os.Bundle;

import android.support.v4.app.Fragment;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;





/**

 * A simple {@link Fragment} subclass.

 * Activities that contain this fragment must implement the

 * {@link TwoFragment.OnFragmentInteractionListener} interface

 * to handle interaction events.

 * Use the {@link TwoFragment#newInstance} factory method to

 * create an instance of this fragment.

 */

public class TwoFragment extends Fragment {

    // TODO: Rename parameter arguments, choose names that match

    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER

    private static final String ARG_PARAM1 = "param1";

    private static final String ARG_PARAM2 = "param2";



    // TODO: Rename and change types of parameters

    private String mParam1;

    private String mParam2;



    private OnFragmentInteractionListener mListener;



    public TwoFragment() {

        // Required empty public constructor

    }



    /**

     * Use this factory method to create a new instance of

     * this fragment using the provided parameters.

     *

     * @param param1 Parameter 1.

     * @param param2 Parameter 2.

     * @return A new instance of fragment TwoFragment.

     */

    // TODO: Rename and change types and number of parameters

    public static TwoFragment newInstance(String param1, String param2) {

        TwoFragment fragment = new TwoFragment();

        Bundle args = new Bundle();

        args.putString(ARG_PARAM1, param1);

        args.putString(ARG_PARAM2, param2);

        fragment.setArguments(args);

        return fragment;

    }



    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        if (getArguments() != null) {

            mParam1 = getArguments().getString(ARG_PARAM1);

            mParam2 = getArguments().getString(ARG_PARAM2);

        }

    }



    @Override

    public View onCreateView(LayoutInflater inflater, ViewGroup container,

                             Bundle savedInstanceState) {

        // Inflate the layout for this fragment

        return inflater.inflate(R.layout.fragment_two, container, false);

    }



    // TODO: Rename method, update argument and hook method into UI event

    public void onButtonPressed(Uri uri) {

        if (mListener != null) {

            mListener.onFragmentInteraction(uri);

        }

    }



    /*@Override

    public void onAttach(Context context) {

        super.onAttach(context);

        if (context instanceof OnFragmentInteractionListener) {

            mListener = (OnFragmentInteractionListener) context;

        } else {

            throw new RuntimeException(context.toString()

                    + " must implement OnFragmentInteractionListener");

        }

    }*/



    @Override

    public void onDetach() {

        super.onDetach();

        mListener = null;

    }



    /**

     * This interface must be implemented by activities that contain this

     * fragment to allow an interaction in this fragment to be communicated

     * to the activity and potentially other fragments contained in that

     * activity.

     * <p/>

     * See the Android Training lesson <a href=

     * "http://developer.android.com/training/basics/fragments/communicating.html"

     * >Communicating with Other Fragments</a> for more information.

     */

    public interface OnFragmentInteractionListener {

        // TODO: Update argument type and name

        void onFragmentInteraction(Uri uri);

    }

}

fragment_two.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context="com.devilsparadise9.mihir.fragmenttabexample.TwoFragment">



    <!-- TODO: Update blank fragment layout -->

    <TextView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="Fragment TWO"

        android:layout_gravity="center"

        android:typeface="serif"

        android:textStyle="bold"

        android:textSize="30dp" />

</FrameLayout>

ThreeFragment.java
package com.devilsparadise9.mihir.fragmenttabexample;



import android.net.Uri;

import android.os.Bundle;

import android.support.v4.app.Fragment;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;





/**

 * A simple {@link Fragment} subclass.

 * Activities that contain this fragment must implement the

 * {@link ThreeFragment.OnFragmentInteractionListener} interface

 * to handle interaction events.

 * Use the {@link ThreeFragment#newInstance} factory method to

 * create an instance of this fragment.

 */

public class ThreeFragment extends Fragment {

    // TODO: Rename parameter arguments, choose names that match

    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER

    private static final String ARG_PARAM1 = "param1";

    private static final String ARG_PARAM2 = "param2";



    // TODO: Rename and change types of parameters

    private String mParam1;

    private String mParam2;



    private OnFragmentInteractionListener mListener;



    public ThreeFragment() {

        // Required empty public constructor

    }



    /**

     * Use this factory method to create a new instance of

     * this fragment using the provided parameters.

     *

     * @param param1 Parameter 1.

     * @param param2 Parameter 2.

     * @return A new instance of fragment ThreeFragment.

     */

    // TODO: Rename and change types and number of parameters

    public static ThreeFragment newInstance(String param1, String param2) {

        ThreeFragment fragment = new ThreeFragment();

        Bundle args = new Bundle();

        args.putString(ARG_PARAM1, param1);

        args.putString(ARG_PARAM2, param2);

        fragment.setArguments(args);

        return fragment;

    }



    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        if (getArguments() != null) {

            mParam1 = getArguments().getString(ARG_PARAM1);

            mParam2 = getArguments().getString(ARG_PARAM2);

        }

    }



    @Override

    public View onCreateView(LayoutInflater inflater, ViewGroup container,

                             Bundle savedInstanceState) {

        // Inflate the layout for this fragment

        return inflater.inflate(R.layout.fragment_three, container, false);

    }



    // TODO: Rename method, update argument and hook method into UI event

    public void onButtonPressed(Uri uri) {

        if (mListener != null) {

            mListener.onFragmentInteraction(uri);

        }

    }



    /*@Override

    public void onAttach(Context context) {

        super.onAttach(context);

        if (context instanceof OnFragmentInteractionListener) {

            mListener = (OnFragmentInteractionListener) context;

        } else {

            throw new RuntimeException(context.toString()

                    + " must implement OnFragmentInteractionListener");

        }

    }*/



    @Override

    public void onDetach() {

        super.onDetach();

        mListener = null;

    }



    /**

     * This interface must be implemented by activities that contain this

     * fragment to allow an interaction in this fragment to be communicated

     * to the activity and potentially other fragments contained in that

     * activity.

     * <p/>

     * See the Android Training lesson <a href=

     * "http://developer.android.com/training/basics/fragments/communicating.html"

     * >Communicating with Other Fragments</a> for more information.

     */

    public interface OnFragmentInteractionListener {

        // TODO: Update argument type and name

        void onFragmentInteraction(Uri uri);

    }

}

fragment_three.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context="com.devilsparadise9.mihir.fragmenttabexample.ThreeFragment">



    <!-- TODO: Update blank fragment layout -->

    <TextView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="Fragment THREE"

        android:layout_gravity="center"

        android:typeface="serif"

        android:textStyle="bold"

        android:textSize="30dp" />



</FrameLayout>

OutPut


If You Want Icon In Tab Then Use Following Code In MainActivity
MainActivity.java
package com.devilsparadise9.mihir.fragmenttabexample;



import android.os.Bundle;

import android.support.design.widget.TabLayout;

import android.support.v4.app.Fragment;

import android.support.v4.app.FragmentManager;

import android.support.v4.app.FragmentPagerAdapter;

import android.support.v4.view.ViewPager;

import android.support.v7.app.AppCompatActivity;

import android.support.v7.widget.Toolbar;

import java.util.ArrayList;

import java.util.List;



public class MainActivity extends AppCompatActivity {



    private Toolbar toolbar;

    private TabLayout tabLayout;

    private ViewPager viewPager;

    //for icon in tab

    private int[] tabIcons = {

            R.mipmap.ic_launcher,

            R.mipmap.ic_launcher,

            R.mipmap.ic_launcher

    };



    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);



        toolbar = (Toolbar) findViewById(R.id.toolbar);

        setSupportActionBar(toolbar);

        getSupportActionBar().setDisplayHomeAsUpEnabled(false);



        viewPager = (ViewPager) findViewById(R.id.viewpager);

        setupViewPager(viewPager);



        tabLayout = (TabLayout) findViewById(R.id.tabs);

        tabLayout.setupWithViewPager(viewPager);

        //for tab icons

        setupTabIcons();

    }



    //for tab icons

    private void setupTabIcons() {



        tabLayout.getTabAt(0).setIcon(tabIcons[0]);

        tabLayout.getTabAt(1).setIcon(tabIcons[1]);

        tabLayout.getTabAt(2).setIcon(tabIcons[2]);

    }



    private void setupViewPager(ViewPager viewPager) {

        ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());

        adapter.addFrag(new OneFragment(), "");

        adapter.addFrag(new TwoFragment(), "");

        adapter.addFrag(new ThreeFragment(), "");

        viewPager.setAdapter(adapter);

    }



    class ViewPagerAdapter extends FragmentPagerAdapter {

        private final List<Fragment> mFragmentList = new ArrayList<>();

        private final List<String> mFragmentTitleList = new ArrayList<>();



        public ViewPagerAdapter(FragmentManager manager) {

            super(manager);

        }



        @Override

        public Fragment getItem(int position) {

            return mFragmentList.get(position);

        }



        @Override

        public int getCount() {

            return mFragmentList.size();

        }



        public void addFrag(Fragment fragment, String title) {

            mFragmentList.add(fragment);

            mFragmentTitleList.add(title);

        }



        @Override

        public CharSequence getPageTitle(int position) {

            return mFragmentTitleList.get(position);

        }

    }

}

OutPut


CCAvenue Payment Gateway Android Integration

CCAvenue Payment Gateway Android Integration CCAvenue payment gateway android integration using PHP RSA and Response Handling. An...