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.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
import com.nusecond.suredeal.app.R;
import com.nusecond.suredeal.app.suredeal.activity.MainActivity;
import com.nusecond.suredeal.app.suredeal.activity.Promo;
import com.nusecond.suredeal.app.suredeal.pojo.Campaigns;
import java.util.ArrayList;
import java.util.List;
/**
* Created by ns2 on 2/4/16.
*/
public class CustomPromoAdapter extends BaseAdapter{
private Activity activity;
private LayoutInflater inflater;
private List<Campaigns> campaigns;
ImageLoader imageLoader = AppController.getInstance().getImageLoader();
public CustomPromoAdapter(Activity activity, List<Campaigns> campaigns){
this.activity=activity;
this.campaigns=campaigns;
}
@Override
public int getCount() {
return campaigns.size();
}
@Override
public Object getItem(int location) {
return campaigns.get(location);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (inflater==null)
inflater=(LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView==null)
convertView=inflater.inflate(R.layout.promo_gridlist,null);
if (imageLoader == null)
imageLoader = AppController.getInstance().getImageLoader();
NetworkImageView thumbNail = (NetworkImageView) convertView
.findViewById(R.id.thumbnail1);
TextView tView = (TextView)convertView.findViewById(R.id.textView1);
// tView.setLayoutParams(new LinearLayout.LayoutParams(5, 5));
Campaigns ca=campaigns.get(position);
tView.setText(ca.getName());
ImageView imgView = (ImageView)convertView.findViewById(R.id.imageView1);
thumbNail.setImageUrl(ca.getImage(), imageLoader);
return convertView;
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/thumbnail1"
android:layout_width="88dp"
android:layout_gravity="center"
android:layout_height="88dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"/>
<ImageView
android:id="@+id/imageView1"
android:layout_gravity="center"
android:layout_width="88dp"
android:layout_height="88dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
/>
<TextView
android:id="@+id/textView1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:text="TextView" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".suredeal.activity.Promo" >
<GridView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:numColumns="2" >
</GridView>
</RelativeLayout>
This is What I'm Displaying With The Above Code..
This is What I'm Trying To Do...