Open arpit999bicubic opened 7 years ago
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); } }
I used this code see my fragment. My app is not crash but ripple effect not work please help me. What should i do??