Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.tulpar.restapi.restapi;
- import android.app.Activity;
- import android.graphics.Bitmap;
- import android.graphics.BitmapFactory;
- import android.util.Log;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.ArrayAdapter;
- import android.widget.ImageView;
- import android.widget.TextView;
- import com.google.gson.Gson;
- import com.tulpar.restapi.restapi.models.Service;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.List;
- /**
- * Created by tegar on 14/06/16.
- */
- public class ServiceAdapter extends ArrayAdapter<String> {
- private final Activity context;
- private final String[] name;
- private final String[] icon;
- private List<Service> service;
- Bitmap bitmap;
- public static final String ROOT_URL = "http://kece.id/";
- public ServiceAdapter(Activity context, List<Service> services) {
- super(context, R.layout.content_main);
- this.context=context;
- this.name = new String[services.size()];
- this.icon = new String[services.size()];
- this.service = services;
- Log.i("Tag", "Name data " + new Gson().toJson(services));
- }
- public View getView(int position,View view,ViewGroup parent) {
- LayoutInflater inflater=context.getLayoutInflater();
- View rowView=inflater.inflate(R.layout.content_main, null, true);
- Log.i("Tag", "Name data2 " + new Gson().toJson(service));
- for (int i = 0; i < service.size(); i++) {
- name[i] = service.get(i).getName();
- icon[i] = service.get(i).getIcon();
- }
- TextView name2 = (TextView) rowView.findViewById(R.id.name);
- Log.i("Tag", "Name data3 " + new Gson().toJson(name));
- name2.setText(new Gson().toJson(name));
- return rowView;
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment