Tuesday, August 16, 2011

[android-developers] Re: Clickable (when select it shows Orange) items within a ListView

Here is my layout - its just a ListView where each ListView item is a
combination of 2 linear layouts. I am trying to make the second
linear layout "clickable", so that when you press it you see orange.
Almost like having a horizontal scrollable ListView within each main
(vertical) ListView.

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_weight=".8"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:id="@+id/firstHorizontal"
android:layout_alignParentLeft="true"
android:layout_width="fill_parent">

<TextView
android:text="Request Title Here - and it is a very long
title that should wrap"
android:layout_gravity="top"
android:textSize="26sp"
android:textColor="#ff000000"
android:id="@+id/request_title"
android:layout_height="wrap_content"
android:lines="1" android:singleLine="true"
android:layout_width="wrap_content">
</TextView>
</LinearLayout>

<!-- its this second LinearLayout that I want to be
able to touch and have it show Orange, so the user knows it was
selected -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/secondHorizontal"
android:layout_weight=".2"
android:orientation="horizontal"
android:layout_alignParentRight="true"
android:paddingLeft="4sp"
android:focusable="true"
android:clickable="true"
android:layout_height="fill_parent"

android:gravity="center_vertical|right"

android:layout_width="55sp">
<ImageView
android:id="@+id/info"
android:focusable="false"
android:hapticFeedbackEnabled="true"
android:soundEffectsEnabled="true"
android:layout_width="35sp"
android:layout_height="40sp"
android:src="@drawable/manage"
android:paddingTop="1sp"
android:scaleType="center"
android:enabled="false"
android:layout_weight="2"
android:paddingLeft="5sp"
android:paddingRight="1sp"
android:layout_centerVertical="true" />
</LinearLayout>


On Aug 14, 6:35 pm, Nick Longinow <nicklongi...@gmail.com> wrote:
> The Contact listing in Android is a great example. It's a listview of
> Contacts, and the items on each row are separated by vertical lines.
> The rightmost item is a Phone icon and when you touch it, it selects
> by showing Orange, just like if you select the main row of any
> ListView.  Does anyone know how that is done?  Is it just an attribute
> of the layout item.  ie, if the row is a LinearLayout with an
> ImageView in the rightmost cell, do you set an attribute on the
> ImageView or do you set an attribute of the LinearLayout?
>
> Hoping this is an easy one.  Still experimenting with it myself.

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

No comments:

Post a Comment