Skip to content

Instantly share code, notes, and snippets.

@gmsetiawan
Created July 6, 2014 09:31
Show Gist options
  • Select an option

  • Save gmsetiawan/36541769beeabd1ef194 to your computer and use it in GitHub Desktop.

Select an option

Save gmsetiawan/36541769beeabd1ef194 to your computer and use it in GitHub Desktop.
package com.example.droidclass;
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
return rootView;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment