2017-02-18 97 views
0

我正在使用android.app.Fragment,是否有人請幫我理解爲什麼我在FG下面出現紅線錯誤時,試圖將此片段添加到事務中?我沒有正確輸入嗎?我加了下面的截圖:添加片段時出錯

Screenshot

回答

0

使用android.support.v4.app.Fragment並添加片段如下

getSupportFragmentManager() 
      .beginTransaction() 
      .add(R.id.fragment_container, new Fragment_One()) 
      .addToBackStack(null) 
      .commit(); 

您的活動必須擴展AppCompatActivity

+0

非常感謝你,這做到了! – user1987