Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In fragment ripple not working #71

Open
arpit999bicubic opened this issue Nov 16, 2016 · 0 comments
Open

In fragment ripple not working #71

arpit999bicubic opened this issue Nov 16, 2016 · 0 comments

Comments

@arpit999bicubic
Copy link

arpit999bicubic commented Nov 16, 2016

I used this code see my fragment. My app is not crash but ripple effect not work please help me. What should i do??


public class HomeFragment extends Fragment implements View.OnClickListener {

   View bt_next, bt_previous,bt_book_ticket;
   View rootView;
   ClickableViewPager viewPager;

   public HomeFragment() {
       // Required empty public constructor
   }

   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);

   }


   @Override
   public View onCreateView(LayoutInflater inflater, ViewGroup container,
                            Bundle savedInstanceState) {
       rootView = inflater.inflate(R.layout.fragment_home, container, false);

       FindIDs();

       viewPager.setOnItemClickListener(new ClickableViewPager.OnItemClickListener() {
           @Override
           public void onItemClick(int position) {

               Toast.makeText(getActivity(), "Position : "+position, Toast.LENGTH_SHORT).show();

               switch (position){

                   case 0:
                       startActivity(new Intent(getActivity(), AmazingRidesActivity.class));
                       break;
                   case 1:
                       startActivity(new Intent(getActivity(), FoodBeveragesActivity.class));

                       break;
                   case 2:
                       startActivity(new Intent(getActivity(), XochiActivity.class));
                       break;

                   default:

                       break;

               }


           }
       });


       // Inflate the layout for this fragment
       return rootView;
   }

   @Override
   public void onAttach(Context context) {
       super.onAttach(context);

       Activity a;

       if (context instanceof Activity) {
           a = (Activity) context;
       }

   }

   @Override
   public void onDetach() {
       super.onDetach();
   }

   @Override
   public void onClick(View v) {

       switch (v.getId()) {

           case R.id.bt_next:

               viewPager.setCurrentItem(viewPager.getCurrentItem() + 1);

               break;
           case R.id.bt_previous:

               viewPager.setCurrentItem(viewPager.getCurrentItem() - 1);

               break;

           case R.id.bt_book_ticket:

               startActivity(new Intent(getActivity(), SelectDateActivity.class));

               break;
           default:


               break;


       }
   }

   public void FindIDs(){

       viewPager = (ClickableViewPager) rootView.findViewById(R.id.viewpager);
       viewPager.setAdapter(new CustomPagerAdapter(getActivity()));

       bt_next =  rootView.findViewById(R.id.bt_next);
       bt_previous =  rootView.findViewById(R.id.bt_previous);
       bt_book_ticket = rootView.findViewById(R.id.bt_book_ticket);

       MaterialRippleLayout.on(bt_next)
               .rippleColor(Color.parseColor("#FF0000"))
               .rippleAlpha(0.2f)
               .rippleHover(true)
               .create();

       MaterialRippleLayout.on(bt_previous)
               .rippleColor(Color.parseColor("#FF0000"))
               .rippleAlpha(0.2f)
               .rippleHover(true)
               .create();

       MaterialRippleLayout.on(bt_book_ticket)
               .rippleColor(Color.parseColor("#FF0000"))
               .rippleAlpha(0.2f)
               .rippleHover(true)
               .create();

       bt_next.setOnClickListener(this);
       bt_previous.setOnClickListener(this);
       bt_book_ticket.setOnClickListener(this);

   }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant