On Thu, Jan 5, 2012 at 12:04 PM, John Davis <davi...@gmail.com> wrote:
>> Now the view ids.... What layout id do you use to initialize the adapter?
>> Perhaps android.R.layout.<something>?
>
> I did :
>                MyAdapter<String> adapter = new
> MyAdapter<String>(this,android.R.layout.simple_list_item_1, values);

You will notice that this is android.R.layout.simple_list_item_1. You
did not write this layout. Usually, if you are going to go to the
trouble of overriding getView(), you will use your own layout file for
the rows, so you have greater control. For example, if you use your
own layout file for the rows, then you are the one responsible for
setting your own view IDs.

> For what it is worth, I can do this:
>         public View getView(int position, View convertView, ViewGroup parent) 
> {
>         TextView text = new TextView(getContext());
>         text.setText("Hi, I am position " + position);
>         text.setTextColor(Color.parseColor("#64788e"));
>         return  text;
>        }
> That will set the text color to blue, but it will also change the text
> I put in the list.

You are welcome to replace "Hi, I am position " + position with your
actual data associated with that position. In this case, you are
telling Android not to bother inflating
android.R.layout.simple_list_item_1, but instead set the rows to be
what you are specifying here.

This is all covered in that excerpt that I linked to in the previous thread:

http://commonsware.com/Android/excerpt.pdf

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to