これが私のメインです:
package com.example.frags;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
public class NewMessage extends FragmentActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.new_message);
//Set new fragment
FragA fragA = new FragA();
FragmentTransaction transaction = getSupportFragmentManager()
.beginTransaction();
transaction.add(R.id.container_id, fragA);
transaction.commit();
}
}
私の FragA クラス:
package com.example.frags;
import android.os.Bundle;
import android.text.style.SuperscriptSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class FragA extends android.support.v4.app.Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.choose_pill_frag, container, false);
}
}
この問題は、数日前に発生した問題と非常によく似ていますが、そのソリューションをこのアプリケーションに適用していますが、まだ機能しません。
.add
メッセージの下に赤い線が引かれていますThe method add(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, fragA)
別のサンプル アプリケーションでこのコードを記述しているため、これは悪化しています。見た目は同じですが、機能します。