Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 2.31 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. textview background color is not changing on click in popupwindow
  2. <item android:state_focused="true" android:drawable="@drawable/focused" />    
  3. <item android:state_pressed="true" android:drawable="@drawable/pressed" />
  4. <item android:drawable="@drawable/priornone" /> <!-- default --> </selector>
  5.        
  6. TextView manage_list = (TextView)popupView.findViewById(R.id.manage_lists);
  7. manage_list.setOnClickListener(new View.OnClickListener(){
  8.  
  9. public void onClick(View v)
  10. {
  11.  
  12.   Intent myIntent = new Intent(v.getContext(),ManageList.class);
  13.       popupWindow.dismiss();
  14.   startActivity(myIntent);
  15.  
  16.  }});
  17.        
  18. <?xml version="1.0" encoding="utf-8"?>
  19.  
  20.   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  21.  android:layout_width="wrap_content"
  22.  android:layout_height="wrap_content"
  23.   android:background="@drawable/pop_menu_bg"
  24.  android:orientation="vertical"
  25.     >
  26.  
  27. <TextView
  28.     android:layout_width="fill_parent"
  29.     android:layout_height="wrap_content"
  30.     android:id="@+id/manage_lists"
  31.     android:text="Manage lists"
  32.     android:background="@drawable/my_drawable"
  33.  >
  34.  </TextView>
  35.  
  36.  
  37. </LinearLayout>
  38.        
  39. private boolean clicked = false;
  40.  
  41. // ...
  42.  
  43. mytextView.setOnClickListener(new OnClickListener(){
  44.     @Override
  45.     public void onClick(View v){
  46.         clicked = !clicked;
  47.  
  48.         if(clicked){
  49.             mytextView.setBackgroundColor(yourcolorclicked);
  50.         }else{
  51.             mytextView.setBackgroundColor(yourcolorunclicked);
  52.         }
  53.         mytextView.invalidate();
  54.     }
  55. });
  56.        
  57. <?xml version="1.0" encoding="utf-8"?>
  58. <selector xmlns:android="http://schemas.android.com/apk/res/android">
  59. <item android:state_focused="true" android:drawable="@drawable/focused" />
  60. <item android:state_pressed="true" android:drawable="@drawable/activated" />
  61. <item android:drawable="@drawable/priornone" />
  62. </selector>
  63.        
  64. <?xml version="1.0" encoding="utf-8"?>
  65. <selector xmlns:android="http://schemas.android.com/apk/res/android">
  66.     <item android:state_pressed="true"
  67.           android:drawable="@drawable/button_pressed" /> <!-- pressed -->
  68.     <item android:state_focused="true"
  69.           android:drawable="@drawable/button_focused" /> <!-- focused -->
  70.     <item android:state_hovered="true"
  71.           android:drawable="@drawable/button_focused" /> <!-- hovered -->
  72.     <item android:drawable="@drawable/button_normal" /> <!-- default -->
  73. </selector>