문제

I have a MainActivity class that extends FragmentActivity and a SecondActivity that extends Fragment. Now I want to do a class BaseActivity and my classes extend it. How I can do? thanks.

public class MainActivity extends FragmentActivity implements LocationListener, OnClickListener{

    ...

    // THIS LINE USE FRAGMENTACTIVITY ONLY
    mapa = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapaMain)).getMap();

   ...

}

public class SecondActFragment extends Fragment implements OnClickListener, LocationListener { 

      ...
} 
도움이 되었습니까?

해결책

Why do you need a BaseActivity? create a class BaseFragmentActivity and extend FragmentActivity, override the things you need to override there and then you extend your MainActivity as BaseFragmentActivity instead

다른 팁

I think you need two base classes - BaseActivity (or BaseFragmentActivity) and BaseFragment.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top