Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.asusx441n.examplelistviewdinamis;
- import android.app.Activity;
- import android.content.Context;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.BaseAdapter;
- import android.widget.ImageView;
- import android.widget.TextView;
- import com.bumptech.glide.Glide;
- import com.bumptech.glide.load.engine.DiskCacheStrategy;
- import java.util.ArrayList;
- import java.util.HashMap;
- public class AdapterListView extends BaseAdapter {
- Global global = new Global();
- private Activity activity;
- private ArrayList<HashMap<String, String>> data, insertData;
- HashMap<String, String> order;
- private static LayoutInflater inflater = null;
- ImageView img;
- View vi;
- public AdapterListView(Activity a, ArrayList<HashMap<String, String>> d) {
- activity = a;
- data = d;
- inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- }
- public int getCount() {
- return data.size();
- }
- public Object getItem(int position) {
- return position;
- }
- public long getItemId(int position) {
- return position;
- }
- @Override
- public View getView(int i, View view, ViewGroup viewGroup) {
- vi = view;
- if (view == null)
- vi = inflater.inflate(R.layout.activity_main_row, null);
- HashMap<String, String> order = data.get(i);
- TextView judul = (TextView) vi.findViewById(R.id.tv_tittle);
- TextView tv_provinsi = (TextView) vi.findViewById(R.id.tv_provinsi);
- ImageView iv_gambar = (ImageView) vi.findViewById(R.id.iv_gambar);
- judul.setText(order.get(global.DATA_TITLE));
- tv_provinsi.setText(order.get(global.DATA_PROVINSI));
- Glide.with(activity).load(order.get(global.DATA_IMAGE1)).thumbnail(0.5f).crossFade().diskCacheStrategy(DiskCacheStrategy.ALL)
- .into(iv_gambar);
- return vi;
- }
- public HashMap<String, String> getItemDisvisitoril(int position) {
- return data.get(position);
- }
- public void setData(ArrayList<HashMap<String, String>> data) {
- this.data = data;
- }
- public HashMap<String, String> getItemDetail(int position) {
- return data.get(position);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement