I am having the Adapter and Fragment.Fragment consists of image view .Inside image view click listener.I am trying to call an url.This is my code
public class TabFragment1 extends Fragment {
private List<Stores> storesList = new ArrayList<>();
private RecyclerView recyclerView;
private StoresAdapter mAdapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.tab_fragment_1, container, false);
ImageView imageView = (ImageView) view.findViewById(R.id.google);
imageView.setBackgroundResource(R.drawable.animation);
AnimationDrawable frameAnimation = (AnimationDrawable) imageView.getBackground();
frameAnimation.start();
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
recyclerView.setNestedScrollingEnabled(true);
mAdapter = new StoresAdapter(storesList);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(mAdapter);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String url="www.google.com";
Intent google=new Intent(Intent.ACTION_VIEW);
google.setData(Uri.parse(url));
startActivity(google);
}
});
prepareStoresData();
return view;
}
private void prepareStoresData() {
Stores stores;
stores = new Stores("Flipcart", "9 Offers", "Get upto 50% Cashback");
storesList.add(stores);
stores = new Stores("Amazon", "9 Offers", "No Cashback");
storesList.add(stores);
stores = new Stores("Paytm", "2 Offers", "Get upto 50%Cashback");
storesList.add(stores);
stores = new Stores("SnapDeal", "3 Offers", "Get upto 10% Reward Points");
storesList.add(stores);
stores = new Stores("Airtel Online Recharge", "2 Offers", "Get upto 0% Cashback");
storesList.add(stores);
stores = new Stores("Freecharge", "No Offers", "Get upto 0% Cashback");
storesList.add(stores);
stores = new Stores("Ebay", "No Offers", "Get upto 7% Cashback");
storesList.add(stores);
stores = new Stores("Shopclues", "No Offers", "Get upto 6% Cashback");
storesList.add(stores);
stores = new Stores("Panuval Book Store", "No Offers", "Get upto 5% Cashback");
storesList.add(stores);
stores = new Stores("Jabong", "2 Offers", "Get upto 6% Cashback");
storesList.add(stores);
stores = new Stores("Redbus", "1 Offers", "No Cashback");
storesList.add(stores);
stores = new Stores("FirstCry", "1 Offers", "Get upto ₹20 Cashback");
storesList.add(stores);
mAdapter.notifyDataSetChanged();
}
}
I had given my code help me in this.It is Adapter having imageview and it should implement the url pass.