spinner类的onDetachedFromWindow为protected,非同一package不能调用
public void packUpSpinnerPopup(){ try { Class<? extends Spinner> spinner = m_Spinner.getClass();//mSpinner是该类中实例化的Spinner对象 Method method = spinner.getDeclaredMethod("onDetachedFromWindow");//该方法是无参方法 method.setAccessible(true);//使该方法可以被调用 method.invoke(m_Spinner);//mSpinner是该类中实例化的Spinner对象 } catch (Exception e) { // TODO Auto-generated catch block Log.i("info", e.toString()); e.printStackTrace(); } }
时间: 2024-10-09 12:40:17