Last active
January 4, 2016 01:59
-
-
Save Trinea/8552075 to your computer and use it in GitHub Desktop.
SearchView setOnClickListener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void setSearchViewOnClickListener(View v, OnClickListener listener) { | |
if (v instanceof ViewGroup) { | |
ViewGroup group = (ViewGroup)v; | |
int count = group.getChildCount(); | |
for (int i = 0; i < count; i++) { | |
View child = group.getChildAt(i); | |
if (child instanceof LinearLayout || child instanceof RelativeLayout) { | |
setSearchViewOnClickListener(child, listener); | |
} | |
if (child instanceof TextView) { | |
TextView text = (TextView)child; | |
text.setFocusable(false); | |
} | |
child.setOnClickListener(listener); | |
} | |
} | |
} | |
from: http://www.trinea.cn/android/searchview-setonclicklistener-not-working/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment