private BannerViewPager;
public void gettBannerViewPager(){
try {
Class<?> c = null;
try {
c = Class.forName("com.youth.banner.Banner");//获得Class对象,控件的包名
} catch (Exception e) {
e.printStackTrace();
}
Field mLayoutField = c.getDeclaredField("viewPager");//根据属性名称,获得类的属性成员Field
mLayoutField.setAccessible(true);//设置为可访问状态
BannerViewPager viewPager = null;
try {
bannerViewPager = (BannerViewPager) mLayoutField.get(this);//获得该属性对应的对象
if(viewPager == null){
return;
}
} catch (IllegalAccessException e) {
e.printStackTrace();
return;
}
}catch (Exception e) {
e.printStackTrace();
}
}
网友评论