1. Are you ready for the Galaxy S20? Here is everything we know so far!

Change Styles onPressed

Discussion in 'Android Development' started by Markus Taubek, Feb 15, 2011.

  1. Markus Taubek

    Markus Taubek Newbie
    Thread Starter

    Hello,
    I have a Area with some elements: ImageView and TextView
    These elements are in an RelativLayout.
    The RelativeLayout has an onClick Listener.

    Now, I want to change all Colors on the regarding elements.
    Background of RelativLayout, src of ImageView, textColor of TextView and so on

    Is it possible to have an onPressed Listener on a RelativLayout or so.
    Or maybe somebody have an idea, how I could make an complex Element where some data will change, when it is pressed.

    Here my part:
    Code (Text):
    1.  
    2. <RelativeLayout
    3.         android:layout_width="fill_parent"
    4.         android:layout_height="50px"
    5.         android:onClick="onClickActual">
    6.             <ImageView
    7.                     android:id="@+id/lk_txt_actual"
    8.                     android:src="@drawable/home_image"
    9.                     android:layout_alignParentLeft="true"
    10.                     android:layout_width="wrap_content"
    11.                     android:layout_height="wrap_content"
    12.                     android:paddingLeft="20dp"
    13.                     android:layout_centerInParent="true" />
    14.                    
    15.             <TextView
    16.                     android:id="@+id/home_num_actual"
    17.                     android:layout_alignParentRight="true"
    18.                     android:layout_width="wrap_content"
    19.                     android:layout_height="wrap_content"
    20.                     android:text=""
    21.                     android:textColor="@color/btn_text"
    22.                     android:layout_marginRight="20dp"
    23.                     android:paddingLeft="10dp"
    24.                     android:paddingRight="10dp"
    25.                     android:paddingBottom="2dp"
    26.                     android:layout_centerVertical="true"
    27.                     style="@style/home_menu_num"
    28.                     android:visibility="invisible"
    29.                     android:background="@drawable/home_num_shape"/>
    30.            
    31.     </RelativeLayout>
    32.  
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Markus Taubek

    Markus Taubek Newbie
    Thread Starter

    The solution was View.OnTouchListener
     
Loading...
Similar Threads - Change Styles onPressed
  1. kumaranil13k
    Replies:
    2
    Views:
    285
  2. kumaranil13k
    Replies:
    1
    Views:
    277
  3. Afoxx
    Replies:
    1
    Views:
    253
  4. Kelvin Water Treatment
    Replies:
    0
    Views:
    289
  5. DMRG TUE
    Replies:
    1
    Views:
    378
  6. JLSchutt
    Replies:
    12
    Views:
    679
  7. Frederik Frandsen
    Replies:
    0
    Views:
    537
  8. Ivanlc
    Replies:
    8
    Views:
    484
  9. Price D Cobb
    Replies:
    0
    Views:
    756
  10. Kuldip Somwanshi
    Replies:
    0
    Views:
    499

Share This Page

Loading...