How to set banner at top of list view dynamically
<p>i want to set banner(image) at top of list view dynamically.i am calling list view data from webservices .i did this coding in my lazy adapter class but no banner being visible.i wana set banner like this.<img src="http://i.stack.imgur.com/tvLrK.png" alt=""></p>

<pre><code>RelativeLayout layout1 = new RelativeLayout(mContext);
ImageView image = new ImageView(mContext);
LayoutParams params2 = new  LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);              
image.setLayoutParams(params2);
image.setScaleType(ImageView.ScaleType.CENTER);
image.setMaxHeight(50);
image.setMaxWidth(50);
image.getPaddingTop();

image.setImageResource(R.drawable.topheader);
layout1.getPaddingTop();
layout1.addView(image);*/
</code></pre>

<p>i have banner image in my drawable.</p>

<hr>

<p>this is my full code of lazy adpter class</p>

<pre><code>package com.example.jsonparsing;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.RelativeLayout.LayoutParams;

public class LazyAdapter extends BaseAdapter {
int counter = 0;
Context mContext;
Activity a;

public LazyAdapter(Context context) {
this.mContext = context;
this.a = a;
}

public int getCount() {
System.out.println("Called..."+ Constants.vctrCategoryId.size());
return Constants.vctrCategoryId.size();
}

public Object getItem(int position) {
return position;
}

public long getItemId(int position) {
return position;
}

public View getView(int position, View convertView, ViewGroup parent) {

System.out.println("Exception before..");
String strUrl = Constants.vctrImagePath.elementAt(counter).toString();// getting url of the images

System.out.println("Urls...." + strUrl);
URL url =null;
try {
url = new URL(strUrl);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block

e.printStackTrace();
}

Bitmap bitmap = Constants.DownloadImage(strUrl);
Bitmap resized = Bitmap.createScaledBitmap(bitmap, 100, 100, true);
//text.setImageBitmap(bitmap);

/* this coding i did for setting banner

/*RelativeLayout layout1 = new RelativeLayout(mContext);
ImageView image = new ImageView(mContext);
LayoutParams params2 = new  LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
image.setLayoutParams(params2);
image.setScaleType(ImageView.ScaleType.CENTER);
image.setMaxHeight(50);
image.setMaxWidth(50);
image.getPaddingTop();

image.setImageResource(R.drawable.topheader);
layout1.getPaddingTop();
layout1.addView(image);*/


RelativeLayout layout = new RelativeLayout(mContext);
//RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
//layout.setLayoutParams(params);
TextView text1 = new TextView(mContext);
text1.setText(Constants.vctrCategory.elementAt(counter).toString());
LayoutParams params1 = new  LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
text1.setLayoutParams(params1);
text1.setTextSize(20);
text1.setGravity(Gravity.RIGHT);
layout.addView(text1);




ImageView img = new ImageView(mContext);
img.setImageBitmap(resized);


layout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
layout.addView(img);
counter++;
return layout;
}

private void setContentView(ImageView image) {
// TODO Auto-generated method stub

}

}
</code></pre>
