[android-developers] Re: How to change color of ListView child items on focus

2010-11-23 Thread viktor
Why did you use complex item layout?

Use selector as TableLayout background.



On 20 Лис, 21:18, Francesco nolano...@gmail.com wrote:
 Hi all.

 i have a list View in my app (this is the xml layout):

 ?xml version=1.0 encoding=utf-8?
 ListView xmlns:android=http://schemas.android.com/apk/res/android;
         android:id=@+id/arrayList
         android:layout_width=fill_parent
 android:layout_height=fill_parent
         android:textFilterEnabled=true
         android:scrollbars=vertical
         android:drawSelectorOnTop=true
 /ListView

 Each item of my list View is composed of two TextView:

 ?xml version=1.0 encoding=utf-8?
 TableLayout android:layout_width=fill_parent
         xmlns:android=http://schemas.android.com/apk/res/android;
 android:id=@+id/row_container
         android:padding=5px android:layout_height=wrap_content
         android:background=@color/white android:shrinkColumns=0
                 TableRow
                 TextView android:layout_height=wrap_content
                         android:layout_width=wrap_content 
 android:layout_below=@+id/
 description
                         android:id=@+id/description
                         android:textColor=@color/black
                         android:scrollHorizontally=true
                         android:singleLine=true/TextView
         /TableRow
         TableRow
                 TextView android:layout_width=wrap_content
                         android:layout_height=wrap_content 
 android:id=@+id/result
                         android:textColor=@color/grey
                         android:maxLines=1
                         android:scrollHorizontally=true/TextView
         /TableRow

 /TableLayout

 I would like to change background color (and text color) of each item
 of my ListView on focus (and, if possibile on selection). How can i do
 it?

 Thanks to all
 francesco

-- 
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


[android-developers] Re: How to change color of ListView child items on focus

2010-11-23 Thread sat
I dint go through ur xml , But I will give an idea.
implemet OnListItemClick handler of listview and we get access to the
child views , and u can change the background color using it.

On Nov 23, 4:23 pm, viktor victor.scherb...@gmail.com wrote:
 Why did you use complex item layout?

 Use selector as TableLayout background.

 On 20 Лис, 21:18, Francesco nolano...@gmail.com wrote:

  Hi all.

  i have a list View in my app (this is the xml layout):

  ?xml version=1.0 encoding=utf-8?
  ListView xmlns:android=http://schemas.android.com/apk/res/android;
          android:id=@+id/arrayList
          android:layout_width=fill_parent
  android:layout_height=fill_parent
          android:textFilterEnabled=true
          android:scrollbars=vertical
          android:drawSelectorOnTop=true
  /ListView

  Each item of my list View is composed of two TextView:

  ?xml version=1.0 encoding=utf-8?
  TableLayout android:layout_width=fill_parent
          xmlns:android=http://schemas.android.com/apk/res/android;
  android:id=@+id/row_container
          android:padding=5px android:layout_height=wrap_content
          android:background=@color/white android:shrinkColumns=0
                  TableRow
                  TextView android:layout_height=wrap_content
                          android:layout_width=wrap_content 
  android:layout_below=@+id/
  description
                          android:id=@+id/description
                          android:textColor=@color/black
                          android:scrollHorizontally=true
                          android:singleLine=true/TextView
          /TableRow
          TableRow
                  TextView android:layout_width=wrap_content
                          android:layout_height=wrap_content 
  android:id=@+id/result
                          android:textColor=@color/grey
                          android:maxLines=1
                          android:scrollHorizontally=true/TextView
          /TableRow

  /TableLayout

  I would like to change background color (and text color) of each item
  of my ListView on focus (and, if possibile on selection). How can i do
  it?

  Thanks to all
  francesco

-- 
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


[android-developers] Re: How to change color of ListView child items on focus

2010-11-23 Thread viktor
sat, it is not correct, because Francesco wants use a focus.

On 23 Лис, 13:47, sat sathvikm...@gmail.com wrote:
 I dint go through ur xml , But I will give an idea.
 implemet OnListItemClick handler of listview and we get access to the
 child views , and u can change the background color using it.

 On Nov 23, 4:23 pm, viktor victor.scherb...@gmail.com wrote:







  Why did you use complex item layout?

  Use selector as TableLayout background.

  On 20 Лис, 21:18, Francesco nolano...@gmail.com wrote:

   Hi all.

   i have a list View in my app (this is the xml layout):

   ?xml version=1.0 encoding=utf-8?
   ListView xmlns:android=http://schemas.android.com/apk/res/android;
           android:id=@+id/arrayList
           android:layout_width=fill_parent
   android:layout_height=fill_parent
           android:textFilterEnabled=true
           android:scrollbars=vertical
           android:drawSelectorOnTop=true
   /ListView

   Each item of my list View is composed of two TextView:

   ?xml version=1.0 encoding=utf-8?
   TableLayout android:layout_width=fill_parent
           xmlns:android=http://schemas.android.com/apk/res/android;
   android:id=@+id/row_container
           android:padding=5px android:layout_height=wrap_content
           android:background=@color/white android:shrinkColumns=0
                   TableRow
                   TextView android:layout_height=wrap_content
                           android:layout_width=wrap_content 
   android:layout_below=@+id/
   description
                           android:id=@+id/description
                           android:textColor=@color/black
                           android:scrollHorizontally=true
                           android:singleLine=true/TextView
           /TableRow
           TableRow
                   TextView android:layout_width=wrap_content
                           android:layout_height=wrap_content 
   android:id=@+id/result
                           android:textColor=@color/grey
                           android:maxLines=1
                           android:scrollHorizontally=true/TextView
           /TableRow

   /TableLayout

   I would like to change background color (and text color) of each item
   of my ListView on focus (and, if possibile on selection). How can i do
   it?

   Thanks to all
   francesco

-- 
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


Re: [android-developers] Re: How to change color of ListView child items on focus

2010-11-23 Thread Kumar Bibek
Changing the background color is too much code, however, although it works.

A better way to get this going is by using StateListDrawables. Create your
own state list drawable, and set it as the background to each of your items,
or the as the selector of the ListView.

Kumar Bibek
http://techdroid.kbeanie.com
http://www.kbeanie.com



On Tue, Nov 23, 2010 at 7:25 PM, viktor victor.scherb...@gmail.com wrote:

 sat, it is not correct, because Francesco wants use a focus.

 On 23 Лис, 13:47, sat sathvikm...@gmail.com wrote:
  I dint go through ur xml , But I will give an idea.
  implemet OnListItemClick handler of listview and we get access to the
  child views , and u can change the background color using it.
 
  On Nov 23, 4:23 pm, viktor victor.scherb...@gmail.com wrote:
 
 
 
 
 
 
 
   Why did you use complex item layout?
 
   Use selector as TableLayout background.
 
   On 20 Лис, 21:18, Francesco nolano...@gmail.com wrote:
 
Hi all.
 
i have a list View in my app (this is the xml layout):
 
?xml version=1.0 encoding=utf-8?
ListView xmlns:android=http://schemas.android.com/apk/res/android;
android:id=@+id/arrayList
android:layout_width=fill_parent
android:layout_height=fill_parent
android:textFilterEnabled=true
android:scrollbars=vertical
android:drawSelectorOnTop=true
/ListView
 
Each item of my list View is composed of two TextView:
 
?xml version=1.0 encoding=utf-8?
TableLayout android:layout_width=fill_parent
xmlns:android=http://schemas.android.com/apk/res/android;
android:id=@+id/row_container
android:padding=5px android:layout_height=wrap_content
android:background=@color/white android:shrinkColumns=0
TableRow
TextView android:layout_height=wrap_content
android:layout_width=wrap_content
 android:layout_below=@+id/
description
android:id=@+id/description
android:textColor=@color/black
android:scrollHorizontally=true
android:singleLine=true/TextView
/TableRow
TableRow
TextView android:layout_width=wrap_content
android:layout_height=wrap_content
 android:id=@+id/result
android:textColor=@color/grey
android:maxLines=1
android:scrollHorizontally=true/TextView
/TableRow
 
/TableLayout
 
I would like to change background color (and text color) of each item
of my ListView on focus (and, if possibile on selection). How can i
 do
it?
 
Thanks to all
francesco

 --
 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.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
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

[android-developers] Re: How to change color of ListView child items on focus

2010-11-23 Thread sat
@Viktor -- Yeah , Whatever I told is for OnClick , since he said on
selection , Click event can be one mode of selection.

On Nov 23, 6:55 pm, viktor victor.scherb...@gmail.com wrote:
 sat, it is not correct, because Francesco wants use a focus.

 On 23 Лис, 13:47, sat sathvikm...@gmail.com wrote:

  I dint go through ur xml , But I will give an idea.
  implemet OnListItemClick handler of listview and we get access to the
  child views , and u can change the background color using it.

  On Nov 23, 4:23 pm, viktor victor.scherb...@gmail.com wrote:

   Why did you use complex item layout?

   Use selector as TableLayout background.

   On 20 Лис, 21:18, Francesco nolano...@gmail.com wrote:

Hi all.

i have a list View in my app (this is the xml layout):

?xml version=1.0 encoding=utf-8?
ListView xmlns:android=http://schemas.android.com/apk/res/android;
        android:id=@+id/arrayList
        android:layout_width=fill_parent
android:layout_height=fill_parent
        android:textFilterEnabled=true
        android:scrollbars=vertical
        android:drawSelectorOnTop=true
/ListView

Each item of my list View is composed of two TextView:

?xml version=1.0 encoding=utf-8?
TableLayout android:layout_width=fill_parent
        xmlns:android=http://schemas.android.com/apk/res/android;
android:id=@+id/row_container
        android:padding=5px android:layout_height=wrap_content
        android:background=@color/white android:shrinkColumns=0
                TableRow
                TextView android:layout_height=wrap_content
                        android:layout_width=wrap_content 
android:layout_below=@+id/
description
                        android:id=@+id/description
                        android:textColor=@color/black
                        android:scrollHorizontally=true
                        android:singleLine=true/TextView
        /TableRow
        TableRow
                TextView android:layout_width=wrap_content
                        android:layout_height=wrap_content 
android:id=@+id/result
                        android:textColor=@color/grey
                        android:maxLines=1
                        android:scrollHorizontally=true/TextView
        /TableRow

/TableLayout

I would like to change background color (and text color) of each item
of my ListView on focus (and, if possibile on selection). How can i do
it?

Thanks to all
francesco



-- 
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