- textview background color is not changing on click in popupwindow
- <item android:state_focused="true" android:drawable="@drawable/focused" />
- <item android:state_pressed="true" android:drawable="@drawable/pressed" />
- <item android:drawable="@drawable/priornone" /> <!-- default --> </selector>
- TextView manage_list = (TextView)popupView.findViewById(R.id.manage_lists);
- manage_list.setOnClickListener(new View.OnClickListener(){
- public void onClick(View v)
- {
- Intent myIntent = new Intent(v.getContext(),ManageList.class);
- popupWindow.dismiss();
- startActivity(myIntent);
- }});
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/pop_menu_bg"
- android:orientation="vertical"
- >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:id="@+id/manage_lists"
- android:text="Manage lists"
- android:background="@drawable/my_drawable"
- >
- </TextView>
- </LinearLayout>
- private boolean clicked = false;
- // ...
- mytextView.setOnClickListener(new OnClickListener(){
- @Override
- public void onClick(View v){
- clicked = !clicked;
- if(clicked){
- mytextView.setBackgroundColor(yourcolorclicked);
- }else{
- mytextView.setBackgroundColor(yourcolorunclicked);
- }
- mytextView.invalidate();
- }
- });
- <?xml version="1.0" encoding="utf-8"?>
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_focused="true" android:drawable="@drawable/focused" />
- <item android:state_pressed="true" android:drawable="@drawable/activated" />
- <item android:drawable="@drawable/priornone" />
- </selector>
- <?xml version="1.0" encoding="utf-8"?>
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_pressed="true"
- android:drawable="@drawable/button_pressed" /> <!-- pressed -->
- <item android:state_focused="true"
- android:drawable="@drawable/button_focused" /> <!-- focused -->
- <item android:state_hovered="true"
- android:drawable="@drawable/button_focused" /> <!-- hovered -->
- <item android:drawable="@drawable/button_normal" /> <!-- default -->
- </selector>