2016-03-20 20 views
0

我的活動應該繼承另一個活動(我無權訪問的另一個庫),我需要在新Activity中集成ActionBar + Fragments。我已經使用AppCompatDelegate將操作欄與成功進行了整合。AppcompatDelegate getSupportFragmentManager()

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    //the installViewFactory method replaces the default widgets 
    //with the AppCompat-tinted versions 
    getDelegate().installViewFactory(); 

    super.onCreate(savedInstanceState); 

    getDelegate().onCreate(savedInstanceState); 

    getDelegate().setContentView(R.layout.activity_profile); 
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    getDelegate().setSupportActionBar(toolbar); 
    getDelegate().getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
    ... 
} 

private AppCompatDelegate getDelegate() { 
    if (mDelegate == null) { 
     mDelegate = AppCompatDelegate.create(this, null); 
    } 
    return mDelegate; 
} 

問題是如何使用片段在這個活動,從android.app.Activity延伸?

注意:這不是FragmentActivity

回答

0

如果android.app.Activity是你唯一的真正的超類,我想你必須使用平臺片段(android.app.Fragment的子類)而不是compat庫片段,它只會使用API​​ 11及更高版本,當它們被引入時。 getFragmentManager()是您的入口點。

+0

感謝Doug,這是我不願意實施的備份解決方案。 appcompat還有許多其他功能,如視圖着色和其他許多功能。我看不到任何其他解決方案,但:( –

相關問題