kandi background
Explore Kits

ViewPagerCards | ViewPager cards inspired by Duolingo

 by   rubensousa Java Version: Current License: Apache-2.0

 by   rubensousa Java Version: Current License: Apache-2.0

Download this library from

kandi X-RAY | ViewPagerCards Summary

ViewPagerCards is a Java library. ViewPagerCards has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub.
ViewPager cards inspired by Duolingo. From my blog post: https://rubensousa.github.io/2016/08/viewpagercards. This is just a sample project. There's support included for Fragments and normal Views. Check the CardPagerAdapter and CardFragmentPagerAdapter classes. Left - Duolingo implementation. Right - This sample.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • ViewPagerCards has a medium active ecosystem.
  • It has 4027 star(s) with 627 fork(s). There are 92 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 15 open issues and 14 have been closed. On average issues are closed in 4 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of ViewPagerCards is current.
ViewPagerCards Support
Best in #Java
Average in #Java
ViewPagerCards Support
Best in #Java
Average in #Java

quality kandi Quality

  • ViewPagerCards has 0 bugs and 0 code smells.
ViewPagerCards Quality
Best in #Java
Average in #Java
ViewPagerCards Quality
Best in #Java
Average in #Java

securitySecurity

  • ViewPagerCards has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • ViewPagerCards code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
ViewPagerCards Security
Best in #Java
Average in #Java
ViewPagerCards Security
Best in #Java
Average in #Java

license License

  • ViewPagerCards is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
ViewPagerCards License
Best in #Java
Average in #Java
ViewPagerCards License
Best in #Java
Average in #Java

buildReuse

  • ViewPagerCards releases are not available. You will need to build from source code and install.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
ViewPagerCards Reuse
Best in #Java
Average in #Java
ViewPagerCards Reuse
Best in #Java
Average in #Java
Top functions reviewed by kandi - BETA

kandi has reviewed ViewPagerCards and discovered the below as its top functions. This is intended to give you an instant insight into ViewPagerCards implemented functionality, and help decide if they suit your requirements.

  • Called when a page has been scrolled .
  • Initializes the adapter .
  • Enables or disables card scaling .
  • This method is used to create a card .
  • Called when a view is clicked .
  • On create card view .
  • Binds a card item to a view
  • Returns the card view at the specified position .
  • Returns the number of fragments .
  • Get the card view

ViewPagerCards Key Features

Showcasing premium features

An app intro

A small gallery of images

License

copy iconCopydownload iconDownload
Copyright 2016 Rúben Sousa

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

How to get view and scroll like make my trip application "Hot Deals" section.?

copy iconCopydownload iconDownload
cardviewPager .addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {


            imagePager.setCurrentItem(position);


        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

ViewPager cards inspired by Duolingo

copy iconCopydownload iconDownload
android:id="@+id/card_button"
Button theButton = (Button) view.findViewById(R.id.card_button);

theButton.setOnClickListener(new View.OnClickListener(){
                    @Override
                    public void onClick(View v){
                        //The Action Here
                    }
                });
-----------------------
android:id="@+id/card_button"
Button theButton = (Button) view.findViewById(R.id.card_button);

theButton.setOnClickListener(new View.OnClickListener(){
                    @Override
                    public void onClick(View v){
                        //The Action Here
                    }
                });
-----------------------
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/cardView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    app:cardUseCompatPadding="true">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical"
            android:padding="24dp">

            <TextView
                android:id="@+id/titleTextView"
                style="@style/TextAppearance.AppCompat.Title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/contentTextView"
                style="@style/TextAppearance.AppCompat.Body1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"/>

            <Button
                android:id="@+id/btn_click"
                style="@style/ButtonStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"
                android:text="Button" />
        </LinearLayout>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top|end"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginTop="-5dp"
            android:src="@drawable/ic_bookmark_24dp" />

    </FrameLayout>

</android.support.v7.widget.CardView>
public class CardPagerAdapter extends PagerAdapter implements CardAdapter {
    Button btn_click;
    private List<CardView> mViews;
    private List<CardItem> mData;
    private float mBaseElevation;
    Context mContext;

    public CardPagerAdapter(MainActivity mainActivity) {
        mData = new ArrayList<>();
        mViews = new ArrayList<>();
        mContext = mainActivity;
    }

    public void addCardItem(CardItem item) {
        mViews.add(null);
        mData.add(item);
    }

    public float getBaseElevation() {
        return mBaseElevation;
    }

    @Override
    public CardView getCardViewAt(int position) {
        return mViews.get(position);
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, final int position) {
        View view = LayoutInflater.from(container.getContext())
                .inflate(R.layout.adapter, container, false);
        container.addView(view);
        bind(mData.get(position), view);
        CardView cardView = (CardView) view.findViewById(R.id.cardView);

        if (mBaseElevation == 0) {
            mBaseElevation = cardView.getCardElevation();
        }

        cardView.setMaxCardElevation(mBaseElevation * MAX_ELEVATION_FACTOR);
        mViews.set(position, cardView);

        btn_click.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(mContext, "List Position " + position, Toast.LENGTH_SHORT).show();
            }
        });

        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
        mViews.set(position, null);
    }

    private void bind(CardItem item, View view) {
        TextView titleTextView = (TextView) view.findViewById(R.id.titleTextView);
        TextView contentTextView = (TextView) view.findViewById(R.id.contentTextView);
        btn_click = (Button) view.findViewById(R.id.btn_click);

        titleTextView.setText(item.getTitle());
        contentTextView.setText(item.getText());

    }

}
    mCardAdapter = new CardPagerAdapter(MainActivity.this);
-----------------------
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/cardView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    app:cardUseCompatPadding="true">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical"
            android:padding="24dp">

            <TextView
                android:id="@+id/titleTextView"
                style="@style/TextAppearance.AppCompat.Title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/contentTextView"
                style="@style/TextAppearance.AppCompat.Body1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"/>

            <Button
                android:id="@+id/btn_click"
                style="@style/ButtonStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"
                android:text="Button" />
        </LinearLayout>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top|end"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginTop="-5dp"
            android:src="@drawable/ic_bookmark_24dp" />

    </FrameLayout>

</android.support.v7.widget.CardView>
public class CardPagerAdapter extends PagerAdapter implements CardAdapter {
    Button btn_click;
    private List<CardView> mViews;
    private List<CardItem> mData;
    private float mBaseElevation;
    Context mContext;

    public CardPagerAdapter(MainActivity mainActivity) {
        mData = new ArrayList<>();
        mViews = new ArrayList<>();
        mContext = mainActivity;
    }

    public void addCardItem(CardItem item) {
        mViews.add(null);
        mData.add(item);
    }

    public float getBaseElevation() {
        return mBaseElevation;
    }

    @Override
    public CardView getCardViewAt(int position) {
        return mViews.get(position);
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, final int position) {
        View view = LayoutInflater.from(container.getContext())
                .inflate(R.layout.adapter, container, false);
        container.addView(view);
        bind(mData.get(position), view);
        CardView cardView = (CardView) view.findViewById(R.id.cardView);

        if (mBaseElevation == 0) {
            mBaseElevation = cardView.getCardElevation();
        }

        cardView.setMaxCardElevation(mBaseElevation * MAX_ELEVATION_FACTOR);
        mViews.set(position, cardView);

        btn_click.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(mContext, "List Position " + position, Toast.LENGTH_SHORT).show();
            }
        });

        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
        mViews.set(position, null);
    }

    private void bind(CardItem item, View view) {
        TextView titleTextView = (TextView) view.findViewById(R.id.titleTextView);
        TextView contentTextView = (TextView) view.findViewById(R.id.contentTextView);
        btn_click = (Button) view.findViewById(R.id.btn_click);

        titleTextView.setText(item.getTitle());
        contentTextView.setText(item.getText());

    }

}
    mCardAdapter = new CardPagerAdapter(MainActivity.this);
-----------------------
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/cardView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    app:cardUseCompatPadding="true">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical"
            android:padding="24dp">

            <TextView
                android:id="@+id/titleTextView"
                style="@style/TextAppearance.AppCompat.Title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/contentTextView"
                style="@style/TextAppearance.AppCompat.Body1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"/>

            <Button
                android:id="@+id/btn_click"
                style="@style/ButtonStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"
                android:text="Button" />
        </LinearLayout>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top|end"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginTop="-5dp"
            android:src="@drawable/ic_bookmark_24dp" />

    </FrameLayout>

</android.support.v7.widget.CardView>
public class CardPagerAdapter extends PagerAdapter implements CardAdapter {
    Button btn_click;
    private List<CardView> mViews;
    private List<CardItem> mData;
    private float mBaseElevation;
    Context mContext;

    public CardPagerAdapter(MainActivity mainActivity) {
        mData = new ArrayList<>();
        mViews = new ArrayList<>();
        mContext = mainActivity;
    }

    public void addCardItem(CardItem item) {
        mViews.add(null);
        mData.add(item);
    }

    public float getBaseElevation() {
        return mBaseElevation;
    }

    @Override
    public CardView getCardViewAt(int position) {
        return mViews.get(position);
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, final int position) {
        View view = LayoutInflater.from(container.getContext())
                .inflate(R.layout.adapter, container, false);
        container.addView(view);
        bind(mData.get(position), view);
        CardView cardView = (CardView) view.findViewById(R.id.cardView);

        if (mBaseElevation == 0) {
            mBaseElevation = cardView.getCardElevation();
        }

        cardView.setMaxCardElevation(mBaseElevation * MAX_ELEVATION_FACTOR);
        mViews.set(position, cardView);

        btn_click.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(mContext, "List Position " + position, Toast.LENGTH_SHORT).show();
            }
        });

        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
        mViews.set(position, null);
    }

    private void bind(CardItem item, View view) {
        TextView titleTextView = (TextView) view.findViewById(R.id.titleTextView);
        TextView contentTextView = (TextView) view.findViewById(R.id.contentTextView);
        btn_click = (Button) view.findViewById(R.id.btn_click);

        titleTextView.setText(item.getTitle());
        contentTextView.setText(item.getText());

    }

}
    mCardAdapter = new CardPagerAdapter(MainActivity.this);

how to set different onclick listener for each button populated by a recyclerview

copy iconCopydownload iconDownload
Switch(position){
case 0:
//Button No.1
break;
case 1:
//Button No.2
break;
.....
}
-----------------------
   public class CategoryAdapter extends RecyclerView.Adapter<CategoryAdapter.ViewHolder> {
    Context context;
    List<Category> list;

    public CategoryAdapter(Context context, List<Category> list){
        this.list = list;
    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        View view = inflater.inflate(R.layout.item_category, null);
        return new CategoryAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, int position) {

        viewHolder.btnOne.setOnItemClickListener(new View.OnItemClickListener{
// do something
});
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        Button btnOne, btnTwo;
        public ViewHolder(View view) {
            super(view);
            btnOne = view.findViewById(R.id.btn_one);
            btnTwo = view.findViewById(R.id.btn_two);

        }
    }

}

Community Discussions

Trending Discussions on ViewPagerCards
  • How to get view and scroll like make my trip application "Hot Deals" section.?
  • ViewPager cards inspired by Duolingo
  • how to set different onclick listener for each button populated by a recyclerview
Trending Discussions on ViewPagerCards

QUESTION

How to get view and scroll like make my trip application "Hot Deals" section.?

Asked 2018-Apr-23 at 13:54

i followed this tutorial "https://github.com/DevExchanges/ViewPagerCards" i got the view like hotdeals section of MMT.But now i also want to change the image while swiping of cardview same as MMT.

ANSWER

Answered 2018-Apr-23 at 13:54

enter image description here

you should be add two viewpager.

One for imagePager and second for cardviewPager

cardviewPager .addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {


            imagePager.setCurrentItem(position);


        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

Source https://stackoverflow.com/questions/49979421

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install ViewPagerCards

You can download it from GitHub.
You can use ViewPagerCards like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the ViewPagerCards component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.