Android examples for User Interface:AdapterView
get On Item Click Listener for AdapterView via reflection
//package com.java2s; import java.lang.reflect.Field; import android.util.Log; import android.widget.AdapterView; public class Main { public static AdapterView.OnItemClickListener getOnItemClickListener( AdapterView view) {// w ww . jav a 2 s . c o m AdapterView.OnItemClickListener listener = null; try { Field listenerField = null; listenerField = getSuperClassOfType(view.getClass(), AdapterView.class.getName()).getDeclaredField( "mOnItemClickListener"); listenerField.setAccessible(true); listener = (AdapterView.OnItemClickListener) listenerField .get(view); } catch (Exception ex) { listener = null; } return listener; } public static Class getSuperClassOfType(Class clazz, String superClassName) { Class tempClass = clazz; while (tempClass != null && !tempClass.getName().equals(superClassName)) tempClass = tempClass.getSuperclass(); Log.i("Recorder", tempClass == null ? "null" : tempClass.getName()); return tempClass; } }