What i am trying to do here is to have a button to add a new entry to my custom listView,something like add to card concept.
However, everything working fine, it is just that when i click the button only one entry is added, and when i click it for the second time nothing changed.
My Fragment
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView=inflater.inflate(R.layout.fragment_port_group, container,false);
injectViews();
mGroupPortAdapter=new GroupPortLazyAdapter(getActivity());
addToList.setOnClickListener(new OnAddToListClickLinsten());
return rootView;
}
public class OnAddToListClickLinsten implements OnClickListener{
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
mGroupPortAdapter.add(new GroupPortInModel("23424",12321324,"0177889062"));
portGroupListView.setAdapter(mGroupPortAdapter);
}
}
This is the lazy Adapter
public class GroupPortLazyAdapter extends ArrayAdapter {
private int[] colors = new int[] { 0x30bebebe, 0x30FFFFFF };
public GroupPortLazyAdapter(Context context) {
super(context, -1);
}
#Override
public View getView(int position, View convertView, ViewGroup arg2) {
ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(
R.layout.port_group_custom_list_view, null);
holder = new ViewHolder();
holder.acountId = (TextView) convertView
.findViewById(R.id.port_account_id);
holder.serialNo = (TextView) convertView
.findViewById(R.id.port_serial_no);
holder.phoneNumber = (TextView) convertView
.findViewById(R.id.port_phone_number);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.acountId.setText(getItem(position).getAcountId());
holder.serialNo
.setText(String.valueOf(getItem(position).getSerialNo()));
holder.phoneNumber.setText(getItem(position).getPhone());
int colorPos = position % colors.length;
convertView.setBackgroundColor(colors[colorPos]);
return convertView;
}
static class ViewHolder {
TextView acountId;
TextView serialNo;
TextView phoneNumber;
int position;
}
}
Have you tried using mGroupPortAdapter.notifyDatasetChanged() instead of portGroupListView.setAdapter(mGroupPortAdapter)?
Also, your try using this as your getView().
#Override
public View getView(int position, View convertView, ViewGroup arg2) {
GroupPortInModel item = getItem(position);
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(
R.layout.port_group_custom_list_view, null);
}
((TextView) convertView.findViewById(R.id.port_account_id))
.setText(item.getAcountId());
((TextView) convertView.findViewById(R.id.port_serial_no))
.setText(item.getSerialNo());
((TextView) convertView.findViewById(R.id.port_phone_number))
.setText(item.getPhone());
int colorPos = position % colors.length;
convertView.setBackgroundColor(colors[colorPos]);
return convertView;
}
Related
i am not able to remove item from arraylist at particular index.
When i am trying to remove item then it is remove from bottom only.
private ArrayList<myproduct> values;
public View getView(final int position, final View convertView,
ViewGroup parent) {
final ViewHolder holder;
View v = convertView;
if (v == null) {
final LayoutInflater vi = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row_favourite, parent, false);
holder = new ViewHolder();
holder.btnaddcollection = (Button) v
.findViewById(R.id.btnaddcollection);
v.setTag(holder);
} else {
holder = (ViewHolder) v.getTag();
}
homeproduct mhomeproduct = values.get(position);
holder.btnaddcollection.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
values.remove(position);
}
});
return v;
}
static class ViewHolder {
public Button btnaddcollection;
}
From above code when i am trying to remove then it is start from bottom to remove .
How can i start to remove item from top with particular position.?
Call notifyDataSetChanged() after you remove the item.
This 'will say' to adapter: "Eh!! data was changed!"
I am creating a custom list view with favorite functionality, but I don't know how to change favorite image background on click. When I simply change the background of favorite icon than it automatically change background of another favorite image background at the time of scrolling. Please check below code :
public class CustomArrayAdapter extends BaseAdapter {
private Activity activity;
private LayoutInflater inflater = null;
ArrayList<Customlist> list;
DecimalFormat formatter = new DecimalFormat("#,##,###");
public CustomArrayAdapter(Activity a, ArrayList<Customlist> list) {
activity = a;
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.list = list;
}
public int getCount() {
return list.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
#Override
public View getView(final int position, View convertView,
final ViewGroup parent) {
TextView txt_unit, txt_state, txt_price, term_left, customr;
TextView install_date;
final ImageView fav;
View view = convertView;
if (convertView == null)
view = inflater.inflate(R.layout.list_item, null);
customr = (TextView) view.findViewById(R.id.customr);
txt_state = (TextView) view.findViewById(R.id.txt_state);
install_date = (TextView) view.findViewById(R.id.install_date);
term_left = (TextView) view.findViewById(R.id.term_left);
txt_price = (TextView) view.findViewById(R.id.txt_price);
fav = (ImageView) view.findViewById(R.id.fav);
txt_unit = (TextView) view.findViewById(R.id.txt_unit);
fav.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
// fav = (ImageView)v.findViewById(R)
fav.setBackgroundResource(R.drawable.favourite_select);
Toast.makeText(activity, "click", 1).show();
}
});
// set values
customr.setText(list.get(position).getCUSTOMER());
txt_state.setText(list.get(position).getSTATE_NAME());
install_date.setText(list.get(position).getINSTALL_DATE());
term_left.setText(list.get(position).getTREM_LEFT());
String price = formatter.format(Integer.parseInt(list.get(position)
.getRUPEES()));
return view;
}
}
First, you need to implement the adapter on ViewHolder pattern:
#Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHoldler holder = null;
if (convertView == null) {
convertView = LayoutInflater.from(ctx).inflate(
R.layout.frag_home_gridview_item, null, false);
holder = new ViewHoldler();
holder.iv = (ImageView) convertView
.findViewById(R.id.gridview_item_label);
holder.tv = (TextView) convertView
.findViewById(R.id.gridview_item_name);
convertView.setTag(holder);
} else {
holder = (ViewHoldler) convertView.getTag();
}
holder.tv.setText(getItem(position));
holder.iv.setImageResource(this.ids[position]);
return convertView;
}
private class ViewHoldler {
ImageView iv;
TextView tv;
}
Second, use partial refreshment mechanism to change the target View's background:
private void refreshPartially(int position){
int firstVisiblePosition = listview.getFirstVisiblePosition();
int lastVisiblePosition = listview.getLastVisiblePosition();
if(position>=firstVisiblePosition && position<=lastVisiblePosition){
View view = listview.getChildAt(position - firstVisiblePosition);
if(view.getTag() instanceof ViewHolder){
ViewHolder vh = (ViewHolder)view.getTag();
//holder.play.setBackgroundResource(resId);//Do something here.
...
}
}
}
Third, add AdapterView.OnItemClickListener to your ListView:
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
refreshPartially(position);
}
});
You need to implement the adapter on ViewHolder pattern:
http://www.vogella.com/tutorials/AndroidListView/article.html
I am creating a custom list view using baseadapter.i have 10 list item in my list.my problem is that afetr 6 items ,the first 4 are repeating.i just printed position values in getview.it gives 0,1,2,3,4,5,6,7,8,9,0,1,2,3.My code is below.
thanx in advance
public class ProductListAdapter extends BaseAdapter implements OnClickListener{
/*
* developer :sanu
* date :10-4-2013
* time :3.34 pm
*/
public View row;
private String[] productName;
private String[] producttype;
private String[] priceRangeFrom;
private String[] priceRangeTo;
private String[] productImage;
private Activity activity;
private static LayoutInflater inflater=null;
static String posClicked;
ViewHolder holder;
Integer height1;
Integer width1;
Typeface tf;
Integer FirmaCount;
public ImageLoader imageLoader;
public ProductListAdapter(Activity a,String[] name,String[] type,String[] price_from,String[] price_to,String[] image,Typeface tf) {
activity = a;
productName = name;
producttype = type;
priceRangeFrom = price_from;
priceRangeTo = price_to;
productImage = image;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return productName.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public int getViewTypeCount (int position)
{
return position;
}
public static class ViewHolder{
public TextView nameProduct;
public TextView typeProduct;
public TextView priceRangeProduct;
public ImageView productImage;
public ImageView plusImage;
public RelativeLayout mainLayout;
public int position;
}
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null){
convertView = inflater.inflate(R.layout.product_list_details,parent, false);
holder=new ViewHolder();
holder.nameProduct =(TextView)convertView.findViewById(R.id.name);
holder.typeProduct =(TextView)convertView.findViewById(R.id.product);
holder.priceRangeProduct =(TextView)convertView.findViewById(R.id.pricerange);
holder.productImage =(ImageView)convertView.findViewById(R.id.image);
holder.plusImage =(ImageView)convertView.findViewById(R.id.dot);
holder.mainLayout = (RelativeLayout)convertView.findViewById(R.id.mainlayout);
holder.nameProduct.setText(productName[position]);
if(producttype[position].length()>18)
{
holder.typeProduct.setText(producttype[position].substring(0,18)+"...");
}
else
{
holder.typeProduct.setText(producttype[position]);
}
holder.priceRangeProduct.setText(priceRangeFrom[position].substring(0,priceRangeFrom[position].length()-2)+" To "+priceRangeTo[position].substring(0, priceRangeTo[position].length()-2));
imageLoader.DisplayImage(productImage[position], holder.productImage);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder)convertView.getTag();
}
holder.plusImage.setTag(Integer.toString(position));
holder.plusImage.setOnClickListener(this);
holder.mainLayout.setTag(Integer.toString(position));
holder.mainLayout.setOnClickListener(this);
return convertView;
}
This sounds like a case of View re-cyclcing. Android will pass a pre-populated view to the getView method. It does so to minimize object creation. When an existing row-view is scrolled off screen, Android might try to recycle that view to display a row that is now on-screen. You need to account for the fact that this view may have been used to display data for another row (which is now off screen).
You have the following line
holder.typeProduct.setText
within the following conditional:
if(convertView == null){
Move that line outside of the conditional, and all should be well.
It's like EJK said. You are not recycling your view correctly. Change your code to this and notice where I put the setText calls
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null){
convertView = inflater.inflate(R.layout.product_list_details,parent, false);
holder=new ViewHolder();
holder.nameProduct =(TextView)convertView.findViewById(R.id.name);
holder.typeProduct =(TextView)convertView.findViewById(R.id.product);
holder.priceRangeProduct =(TextView)convertView.findViewById(R.id.pricerange);
holder.productImage =(ImageView)convertView.findViewById(R.id.image);
holder.plusImage =(ImageView)convertView.findViewById(R.id.dot);
holder.mainLayout = (RelativeLayout)convertView.findViewById(R.id.mainlayout);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder)convertView.getTag();
}
holder.plusImage.setTag(Integer.toString(position));
holder.plusImage.setOnClickListener(this);
holder.mainLayout.setTag(Integer.toString(position));
holder.mainLayout.setOnClickListener(this);
//setText functions are here
holder.nameProduct.setText(productName[position]);
if(producttype[position].length()>18)
{
holder.typeProduct.setText(producttype[position].substring(0,18)+"...");
}
else
{
holder.typeProduct.setText(producttype[position]);
}
holder.priceRangeProduct.setText(priceRangeFrom[position].substring(0,priceRangeFrom[position].length()-2)+" To "+priceRangeTo[position].substring(0, priceRangeTo[position].length()-2));
imageLoader.DisplayImage(productImage[position], holder.productImage);
return convertView;
}
Change your getView to
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null){
convertView = inflater.inflate(R.layout.product_list_details,parent, false);
holder=new ViewHolder();
holder.nameProduct =(TextView)convertView.findViewById(R.id.name);
holder.typeProduct =(TextView)convertView.findViewById(R.id.product);
holder.priceRangeProduct =(TextView)convertView.findViewById(R.id.pricerange);
holder.productImage =(ImageView)convertView.findViewById(R.id.image);
holder.plusImage =(ImageView)convertView.findViewById(R.id.dot);
holder.mainLayout = (RelativeLayout)convertView.findViewById(R.id.mainlayout);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.nameProduct.setText(productName[position]);
if(producttype[position].length()>18)
{
holder.typeProduct.setText(producttype[position].substring(0,18)+"...");
}
else
{
holder.typeProduct.setText(producttype[position]);
}
holder.priceRangeProduct.setText(priceRangeFrom[position].substring(0,priceRangeFrom[position].length()-2)+" To "+priceRangeTo[position].substring(0, priceRangeTo[position].length()-2));
imageLoader.DisplayImage(productImage[position], holder.productImage);
holder.plusImage.setTag(Integer.toString(position));
holder.plusImage.setOnClickListener(this);
holder.mainLayout.setTag(Integer.toString(position));
holder.mainLayout.setOnClickListener(this);
return convertView;
}
Also check this
How ListView's recycling mechanism works
Change getView()
Declare ViewHolder before if (convertView == null)
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.product_list_details,
parent, false);
holder = new ViewHolder();
holder.nameProduct = (TextView) convertView.findViewById(R.id.name);
holder.typeProduct = (TextView) convertView
.findViewById(R.id.product);
holder.priceRangeProduct = (TextView) convertView
.findViewById(R.id.pricerange);
holder.productImage = (ImageView) convertView
.findViewById(R.id.image);
holder.plusImage = (ImageView) convertView.findViewById(R.id.dot);
holder.mainLayout = (RelativeLayout) convertView
.findViewById(R.id.mainlayout);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.nameProduct.setText(productName[position]);
if (producttype[position].length() > 18) {
holder.typeProduct.setText(producttype[position].substring(0, 18)
+ "...");
} else {
holder.typeProduct.setText(producttype[position]);
}
holder.priceRangeProduct.setText(priceRangeFrom[position].substring(0,
priceRangeFrom[position].length() - 2)
+ " To "
+ priceRangeTo[position].substring(0,
priceRangeTo[position].length() - 2));
imageLoader.DisplayImage(productImage[position], holder.productImage);
holder.plusImage.setTag(Integer.toString(position));
holder.plusImage.setOnClickListener(this);
holder.mainLayout.setTag(Integer.toString(position));
holder.mainLayout.setOnClickListener(this);
return convertView;
}
I've checked the array menuItems and it seems good, but there is something wrong in the following code.
When I start it it seems okay but when I start scrolling it gets screwed up and put items on top of the list and duplicates items....it's just weird
public class ScoresAdapter extends BaseAdapter {
private MainActivity activity;
private ScoreItem[] menuItems;
private static LayoutInflater inflater=null;
ImageDownloader downloader;
public ScoresAdapter(MainActivity a, ScoreItem[] scoreItems) {
activity = a;
menuItems = scoreItems;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
downloader = new ImageDownloader();
}
public int getCount() {
int teller = 0;
for(int i = 0 ; menuItems.length > i ; i++){
if(menuItems[i] != null){
teller++;
}
}
return teller;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null){
if(menuItems[position].getId() == 888){
//fav header
vi = inflater.inflate(R.layout.scoresheaderfavoriet, null);
}else if(menuItems[position].getId() == 999){
//overige header
vi = inflater.inflate(R.layout.scoresheaderoverig, null);
}else{
if(menuItems[position].getIsFav()){
vi = inflater.inflate(R.layout.scoresfavitem, null);
}else{
vi = inflater.inflate(R.layout.scoresitem, null);
}
TextView text2=(TextView)vi.findViewById(R.id.position);
text2.setText(""+ menuItems[position].getPosition());
TextView text=(TextView)vi.findViewById(R.id.name);
text.setText(menuItems[position].getFirstName() + " " + menuItems[position].getLastName().toUpperCase());
TextView text5=(TextView)vi.findViewById(R.id.country);
text5.setText(""+ menuItems[position].getCountry());
TextView text3=(TextView)vi.findViewById(R.id.score);
text3.setText(""+ menuItems[position].getScore());
TextView text8=(TextView)vi.findViewById(R.id.hole);
text8.setText(""+ menuItems[position].getHole());
vi.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), SpelerView.class);
intent.putExtra("id", menuItems[position].getId());
v.getContext().startActivity(intent);
activity.sluitAlleMenus();
}
});
}
}
return vi;
}
}
I had the same problem
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
CalendarsData c = (CalendarsData) this.getItem(position);
if (convertView == null) {
holder=new ViewHolder();
convertView = l_Inflater.inflate(R.layout.preference_list_element, null);
holder.text=(CheckBox)convertView.findViewById(R.id.checkTextView);
//holder.tv =(TextView)convertView.findViewById(R.id.textview);
holder.text.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox) v;
CalendarsData ssi = (CalendarsData) cb.getTag();
ssi.setChecked(cb.isChecked());
}
});
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.text.setText("c.anyvalue");
return convertView;
}
like the guys above say you need the else:
} else {
holder = (ViewHolder) convertView.getTag();
I had the same problem once. I think it's because of the adapter's "caching"...You should implement an else like this:
if(convertView==null){
holder = new NodeViewHolder();
//Your stuff
convertView.setTag(holder);
}else{
holder = (NodeViewHolder) convertView.getTag();
}
public static class NodeViewHolder {
TextView text;
TextView text2;
TextView text3;
//So on...
}
It'll be executed when the View is cached (not null)
You aren't handling the case when your convertView was NOT null correctly. Change your code like this:
public View getView(final int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null){
if(menuItems[position].getId() == 888){
//fav header
vi = inflater.inflate(R.layout.scoresheaderfavoriet, null);
}else if(menuItems[position].getId() == 999){
//overige header
vi = inflater.inflate(R.layout.scoresheaderoverig, null);
}else{
if(menuItems[position].getIsFav()){
vi = inflater.inflate(R.layout.scoresfavitem, null);
}else{
vi = inflater.inflate(R.layout.scoresitem, null);
}
}
}
TextView text2=(TextView)vi.findViewById(R.id.position);
text2.setText(""+ menuItems[position].getPosition());
TextView text=(TextView)vi.findViewById(R.id.name);
text.setText(menuItems[position].getFirstName() + " " + menuItems[position].getLastName().toUpperCase());
TextView text5=(TextView)vi.findViewById(R.id.country);
text5.setText(""+ menuItems[position].getCountry());
TextView text3=(TextView)vi.findViewById(R.id.score);
text3.setText(""+ menuItems[position].getScore());
TextView text8=(TextView)vi.findViewById(R.id.hole);
text8.setText(""+ menuItems[position].getHole());
vi.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), SpelerView.class);
intent.putExtra("id", menuItems[position].getId());
v.getContext().startActivity(intent);
activity.sluitAlleMenus();
}
});
return vi;
}
That will get you most the way there. You'll likely have to move some of your favorites and/or header footer logic out of the if(convertView ==null) as well. I can't exactly tell what you are doing with that though, so I wouldn't know for sure how it needs to be.
I am working with simple List view using this code,
public class RadioDemoActivity extends Activity {
ArrayList<String> list = new ArrayList<String>();
MyListAdapter mla;
ListView lv;
int position = -1;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lv = (ListView) findViewById(R.id.listView1);
list.add("one");
list.add("two");
list.add("three");
list.add("four");
list.add("five");
list.add("six");
list.add("seven");
list.add("eight");
list.add("nine");
list.add("ten");
list.add("eleven");
list.add("twelve");
list.add("thirteen");
list.add("fourteen");
list.add("fifteen");
list.add("sixteen");
list.add("seventeen");
list.add("eightteen");
list.add("nineteen");
list.add("twenty");
mla = new MyListAdapter(this);
lv.setAdapter(mla);
}
public class MyListAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public MyListAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return list.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.cust_list, null);
TextView tv = (TextView)convertView.findViewById(R.id.txt_title);
ImageView iv = (ImageView)convertView.findViewById(R.id.imageView1);
tv.setText(list.get(position));
Log.v("log_tag","position In"+list.get(position));
}
return convertView;
}
}
}
but result is like in Image
after eleven its showing me one,one, two.
please help me
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ListHolder holder = null;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.cust_list, null);
holder=new ListHolder();
holder.tv = (TextView)convertView.findViewById(R.id.txt_title);
holder.iv = (ImageView)convertView.findViewById(R.id.imageView1);
Log.v("log_tag","position In"+list.get(position));
convertView.setTag(holder);
}
else
{
holder=(ListHolder) convertView.getTag();
}
holder.tv.setText(list.get(position));
return convertView;
}
static class ListHolder
{
TextView tv;
ImageView iv;
}
Always write else condition in holder.
change your getView() to:
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.cust_list, null);
}
TextView tv = (TextView)convertView.findViewById(R.id.txt_title);
ImageView iv = (ImageView)convertView.findViewById(R.id.imageView1);
tv.setText(list.get(position));
Log.v("log_tag","position In"+list.get(position));
return convertView;
}
Can't add the comment in "right" place, but Niteesh Mehra's suggestion above to put LV in scrollview is wrong. LV is a view that shows items in a vertically scrolling list, so there's no point of doing so again.
As for your problem - your getView() implementation is wrong. You should reuse view given if convertView is not null, but reuse means you got view (layout) already baked, but you still have to fill it with content right for this row. So you should do something like:
if( convertView == null ) {
convertView = <inflate view from XML>;
}
Then you your data in view's elements unconditionally.
I changed my getView() like this and problem solved.
public View getView(int position, View convertView, ViewGroup parent) {
convertView = mInflater.inflate(R.layout.cust_list, null);
TextView tv = (TextView) convertView.findViewById(R.id.txt_title);
ImageView iv = (ImageView) convertView.findViewById(R.id.imageView1);
tv.setText(list.get(position));
tv.setTag(list.get(position));
if (RadioDemoActivity.this.position==position)
iv.setImageResource(R.drawable.greenround);
return convertView;
}
change getView method like this
if (convertView == null) {
convertView = mInflater.inflate(R.layout.cust_list, null);
}
TextView tv = (TextView)convertView.findViewById(R.id.txt_title);
ImageView iv = (ImageView)convertView.findViewById(R.id.imageView1);
tv.setText(list.get(position));
Log.v("log_tag","position In"+list.get(position));