Tuesday, 27 August 2013

Navigation drawer using fragments showing errors.

Navigation drawer using fragments showing errors.

Here is the code.. I have tried importing import
"android.support.v4.app.Fragment", but the error pops up in
"getFragmentManager().beginTransaction().add(R.id.MAIN, details).commit()"
part.
I have no idea, what step I should take, I have been working on this
problem for a while. Any help is appreciated. Or is it possible to
implement navigation drawer without any fragment, but not using sliding
drawer??
`
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class FragmentTwo extends Activity{
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
if(savedInstanceState == null){
DetailsFragment details = new DetailsFragment();
details.setArguments(getIntent().getExtras());
getFragmentManager().beginTransaction().add(R.id.MAIN,
details).commit();
}
}
public static class DetailsFragment extends Fragment{
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState){
return inflater.inflate(R.layout.fragment_two, container, false);
}
}
}`

No comments:

Post a Comment