Trying to get a Fragment
to load in Gingerbread
using android.support.v4.app
but I keep getting the following error:
The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, Welcome)
My Welcome class extends Fragment, not sure what I am doing wrong here?
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
loadfrag();
}
private void loadfrag() {
Welcome frag = new Welcome();
android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.flactivity_main, frag); **<--- line with error**
transaction.commit();
}
}
import android.support.v4.app.Fragment;
public class Welcome extends Fragment{
private final String TAG = this.getClass().getSimpleName();
private ViewGroup mrootview;
private Activity mactivity;
private Context mcontext;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
//mrootview = (ViewGroup)
return inflater.inflate(R.layout.welcome, container, false);
}
}