0

I am trying to add my alternate background code in java to an adapter that is not using getview method. Can any one please guide me how I can override/create the getview method? Here's the code i need to add in getview :

if (position % 2 == 0){
            addView.setBackgroundResource(R.drawable.oddcellcolor);
        } else {
            addView.setBackgroundResource(R.drawable.evencellcolor);
        }

Any help appreciated! Thanks! Justin

MattDavis
  • 5,158
  • 2
  • 23
  • 35
  • 1
    I'm not quite sure what you mean "an adapter that is not using getview method". The Adapter doesn't use getView - it provides getView, and that is used by the AdapterView that owns the Adapter. – Jules May 24 '13 at 19:05

1 Answers1

0

You could just look in the docs for the adaper and find the getView method in there....

but for the lazy this is what you have to override

getView(int position, View convertView, ViewGroup parent)
tyczj
  • 71,600
  • 54
  • 194
  • 296
  • I added the code mentioned here: http://stackoverflow.com/questions/3535074/getview-vs-bindview-in-a-custom-cursoradapter , but everytime i plugged in my code above , it caused crash in the application whenever i went to that page, any clue how to fix the issue? –  May 24 '13 at 19:11
  • @JusticeBauer well you are going to have to give more information like code and the error – tyczj May 24 '13 at 19:12
  • just to reiterate, in the stackoverflow link i sent, one with 4 votes( the answer) , can i use that? as soon as i plug my code if(position%2 ==0) etc.. into it, it doesnt recognize it and crashes, is it possible to create an all new getview method and ass this code right there? or should i follow some other approach? –  May 24 '13 at 20:51
  • you "create a new getview" by overriding the getView so like I said post more code of what you did and post the error – tyczj May 24 '13 at 23:23