2016-11-10 38 views
1

エラー: 'childFragmentManager'パラメータは、android.support.v4.app.FragmentでgetChildFragmentManager()メソッドを使用できる場合にのみ使用でき、サポートライブラリのバージョンを更新します。メソッドgetChildFragmentManager()を解決できません

私は自分のgradleで 'com.android.support:support-v4:24.2.0'をコンパイルしました。私のコードのような;

import android.support.v4.app.Fragment; 
import org.androidannotations.annotations.*; 
import org.androidannotations.annotations.sharedpreferences.Pref; 
. 
. 

@EFragment(R.layout.fragment_main) 
public class MainFragment extends Fragment { 
@Pref 
ApplicationSettings_ applicationSettings; 
@ViewById(R.id.bot) 
public LinearLayout bot; 
@ViewById(R.id.center) 
public LinearLayout center; 
@Bean 
UIItemGenerator uiItemGenerator; 
@SystemService 
LayoutInflater layoutInflater; 
@FragmentById(value = R.id.contentFragment,childFragment = true) 
public ContentFragment contentFragment; 

public MainFragment() { 
} 

@Click(R.id.imagebutton_ribbon) 
public void ribbonClick(View view) { 
    view.setVisibility(View.GONE); 
} 

. 
. 
. 
@AfterViews 
public void afterViews() { 
    if (contentFragment == null) 
     contentFragment = (ContentFragment) this.getChildFragmentManager().findFragmentById(R.id.contentFragment); 
    for (int j = 0; j < bot.getChildCount(); j++) { 
     bot.getChildAt(j).setSelected(false); 
    } 
    for (int j = 0; j < top.getChildCount(); j++) { 
     top.getChildAt(j).setSelected(false); 
    } 
    ll_home.setSelected(true); 
    ll_allrooms.setSelected(true); 
    initUI(); 
    contentFragment.generateContent(-1, -1); 
    imagebutton_top_rightarrow.setSelected(true); 
    imagebutton_bot_rightarrow.setSelected(true); 

答えて

0

getChildFragmentManager()私はあなたがAppCompatActivity(FragmentActivityの子クラス)を使用していると思うフラグメントの方法であり、あなたのimport文

import android.support.v4.app.FragmentManager; 

をチェックし、あなたはこの

getSupportFragmentManager() 
を使用する必要があります
+0

Fragment not Fragment Activityを拡張します。回答を投稿する前に、質問を慎重にチェックしてください。 –

+0

私の答えを編集してくれてありがとう、ありがとう – GvSharma

関連する問題