不是很清楚楼主的需求,你类A都实现了那个接口直接fMgr.findFragmentByTag(tagOfTheFragmentShowing).OnBackKeyClickedEvent();这样写就行了何必要再转成接口

解决方案 »

  1.   


    eclipse报错了,提示The method OnBackKeyClickedEvent() is undefined for the type Fragment我是在做安卓的项目时候碰到的,在activity里面有几个不同的fragment,每一个fragment对用户在按下返回键时都会做出不同的反应,所以我定义了一个接口,让那些fragment去实现,然后我在activity里面去调用这个接口,就可以让那些fragment对同一个事件做出不同的响应了。我定义了一个FileListFragment,它继承了Fragment类,也实现了那个FragmentsNeedToInstance 接口,但是按照你说的那个方法,eclipse会报错,,想不通
      

  2.   


    我用这种方式解决了,,就是在外面套了一层括号。。好感动
    ((FilelistFragment) fMgr.findFragmentByTag(tagOfTheFragmentShowing))
    .OnBackKeyClickedEvent();