Last active
August 29, 2015 14:13
-
-
Save akexorcist/5a7f23d659533375c425 to your computer and use it in GitHub Desktop.
Override OnClick แบบโคตรเหง้าเหล่ากอใน View นั้นๆ
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 anyMethod(View view, Activity activity) { | |
final Activity mActivity = activity; | |
//Set up touch listener for non-text box views to hide keyboard. | |
if(!(view instanceof EditText)) { | |
view.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
// TODO Do something here | |
} | |
}); | |
} | |
//If a layout container, iterate over children and seed recursion. | |
if(view instanceof ViewGroup) { | |
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) { | |
View innerView = ((ViewGroup) view).getChildAt(i); | |
anyMethod(innerView, mActivity); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment