Example usage for android.widget FrameLayout setId

List of usage examples for android.widget FrameLayout setId

Introduction

In this page you can find the example usage for android.widget FrameLayout setId.

Prototype

public void setId(@IdRes int id) 

Source Link

Document

Sets the identifier for this view.

Usage

From source file:com.bradenmacdonald.OverlayedMapFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    FrameLayout layout = new FrameLayout(this);
    layout.setId(LAYOUT_ID);
    setContentView(layout);//from  w  w  w  . ja  v a  2 s .c o m

    //mMapFragment = SupportMapFragment.newInstance(op);
    mMapFragment = new OverlayedMapFragment();
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.add(LAYOUT_ID, mMapFragment);
    fragmentTransaction.commit();
}

From source file:com.lullabot.android.apps.iosched.ui.StarredActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_starred);
    getActivityHelper().setupActionBar(getTitle(), 0);

    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabWidget = (TabWidget) findViewById(android.R.id.tabs);
    mTabHost.setup();//from w w w . j  ava  2  s  .  co  m
    // TODO: this is very inefficient and messy, clean it up
    FrameLayout fragmentContainer = new FrameLayout(this);
    fragmentContainer.setId(R.id.fragment_sessions);
    fragmentContainer.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer);

    final Intent intent = new Intent(Intent.ACTION_VIEW, Sessions.CONTENT_STARRED_URI);

    final FragmentManager fm = getSupportFragmentManager();
    mSessionsFragment = (SessionsFragment) fm.findFragmentByTag("sessions");
    if (mSessionsFragment == null) {
        mSessionsFragment = new SessionsFragment();
        mSessionsFragment.setArguments(intentToFragmentArguments(intent));
        fm.beginTransaction().add(R.id.fragment_sessions, mSessionsFragment, "sessions").commit();
    }

    // Sessions content comes from reused activity
    mTabHost.addTab(mTabHost.newTabSpec(TAG_SESSIONS).setIndicator(buildIndicator(R.string.starred_sessions))
            .setContent(R.id.fragment_sessions));
}

From source file:org.opensilk.iab.gplay.DonateActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    boolean fromConfigurationChange = false;
    mGraph = (ObjectGraph) getLastCustomNonConfigurationInstance();
    if (mGraph == null) {
        if (D)//from   w ww.j  a va  2 s . c om
            Log.d(TAG, "Creating new graph");
        mGraph = ((DaggerInjector) getApplication()).getObjectGraph().plus(new DonateActivityModule());
    } else {
        fromConfigurationChange = true;
    }
    inject(this);
    super.onCreate(savedInstanceState);

    //TODO is this even needed?
    FrameLayout fl = new FrameLayout(this);
    fl.setId(R.id.iab_main);
    setContentView(fl);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (!fromConfigurationChange) {
        getSupportFragmentManager().beginTransaction().add(new PurchaseFragment(), "purchase").commit();
        mIabHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            @Override
            public void onIabSetupFinished(IabResult result) {
                if (D)
                    Log.d(TAG, "onSetupFinished");
                Fragment f = getSupportFragmentManager().findFragmentByTag("donate");
                if (f == null) {
                    f = DonateFragment.newInstance(result.isSuccess());
                }
                getSupportFragmentManager().beginTransaction().replace(R.id.iab_main, f, "donate").commit();
            }
        });
    }
}

From source file:com.github.jobs.ui.activity.BaseActivity.java

/**
 * Helper method that allows to initialize and add a fragment to activities that usually have
 * just one single fragment. Fragment is added using its class.getName() as tag.
 *
 * @param containerId resource id of the fragment container (must be created through android
 * resources)//from w w w . j a  v  a  2  s  . c  o m
 * @param fragmentClass the class of the fragment to setup
 * @param args bundle with the arguments to pass to the fragment
 */
void setupBaseFragment(int containerId, Class<? extends Fragment> fragmentClass, Bundle args) {
    if (mSetContentViewAlreadyCalled) {
        View view = findViewById(containerId);
        if (!(view instanceof ViewGroup)) {
            throw new IllegalStateException(
                    "Since you already called setContentView, it must has a ViewGroup whose id is 'containerId'");
        }
    } else {
        FrameLayout container = new FrameLayout(this);
        container.setId(containerId);
        setContentView(container);
    }

    // let's check whether fragment is already added
    Fragment fragment = findFragment(fragmentClass);
    if (fragment == null) {
        // if not, let's create it and add it
        fragment = Fragment.instantiate(this, fragmentClass.getName(), args);

        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(containerId, fragment, fragmentClass.getSimpleName());
        ft.commit();
    }
}

From source file:com.commonsware.android.arXiv.ArticleList.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    FrameLayout fl = new FrameLayout(this);
    fl.setId(android.R.id.content);
    setContentView(fl);/* ww  w .  j  av a 2 s  .c  om*/

    Intent intent = getIntent();
    name = intent.getStringExtra("keyname");
    query = intent.getStringExtra("keyquery");
    url = intent.getStringExtra("keyurl");
    favorite = intent.getBooleanExtra("favorite", false);

    ActionBar ab = getSupportActionBar();
    ab.setTitle(name);
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setHomeButtonEnabled(true);

    FragmentManager fm = getSupportFragmentManager();
    if (savedInstanceState == null) {
        articleListFragment = new ArticleListFragment();
        FragmentTransaction ft = fm.beginTransaction();
        ft.replace(android.R.id.content, articleListFragment);
        ft.commit();
    } else {
        Fragment f = fm.findFragmentById(android.R.id.content);
        if (f instanceof ArticleListFragment)
            articleListFragment = (ArticleListFragment) f;
    }
}

From source file:com.codebutler.farebot.activities.FragmentWrapperActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    FrameLayout container = new FrameLayout(this);
    container.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    container.setId(R.id.content);
    setContentView(container);//from   w  w w  . j  a v a 2  s. c o m

    if (getFragment() == null) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.content, createFragment(), "fragment");
        transaction.commit();
    }
}

From source file:tw.idv.gasolin.pycontw2012.ui.SearchActivity.java

/**
 * Build and add "sessions" tab.//  ww  w  . j  a v a2 s . c  o  m
 */
private void setupSessionsTab() {
    // TODO: this is very inefficient and messy, clean it up
    FrameLayout fragmentContainer = new FrameLayout(this);
    fragmentContainer.setId(R.id.fragment_sessions);
    fragmentContainer.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer);

    final FragmentManager fm = getSupportFragmentManager();
    mSessionsFragment = (SessionsFragment) fm.findFragmentByTag("sessions");
    if (mSessionsFragment == null) {
        mSessionsFragment = new SessionsFragment();
        mSessionsFragment.setArguments(getSessionsFragmentArguments());
        fm.beginTransaction().add(R.id.fragment_sessions, mSessionsFragment, "sessions").commit();
    }

    // Sessions content comes from reused activity
    mTabHost.addTab(mTabHost.newTabSpec(TAG_SESSIONS).setIndicator(buildIndicator(R.string.starred_sessions))
            .setContent(R.id.fragment_sessions));
}

From source file:com.goliathonline.android.kegbot.ui.StarredActivity.java

/**
 * Build and add "sessions" tab.//from  w w  w.j  ava2s  .  com
 */
private void setupSessionsTab() {
    // TODO: this is very inefficient and messy, clean it up
    FrameLayout fragmentContainer = new FrameLayout(this);
    fragmentContainer.setId(R.id.fragment_drinks);
    fragmentContainer.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer);

    final Intent intent = new Intent(Intent.ACTION_VIEW, Drinks.CONTENT_STARRED_URI);

    final FragmentManager fm = getSupportFragmentManager();
    mDrinksFragment = (DrinksFragment) fm.findFragmentByTag("drinks");
    if (mDrinksFragment == null) {
        mDrinksFragment = new DrinksFragment();
        mDrinksFragment.setArguments(intentToFragmentArguments(intent));
        fm.beginTransaction().add(R.id.fragment_drinks, mDrinksFragment, "drinks").commit();
    }

    // Sessions content comes from reused activity
    mTabHost.addTab(mTabHost.newTabSpec(TAG_DRINKS).setIndicator(buildIndicator(R.string.starred_drinks))
            .setContent(R.id.fragment_drinks));
}

From source file:com.google.android.apps.iosched.ui.StarredActivity.java

/**
 * Build and add "sessions" tab.//from w  ww.  j a v a2s.c  o  m
 */
private void setupSessionsTab() {
    // TODO: this is very inefficient and messy, clean it up
    FrameLayout fragmentContainer = new FrameLayout(this);
    fragmentContainer.setId(R.id.fragment_sessions);
    fragmentContainer.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer);

    final Intent intent = new Intent(Intent.ACTION_VIEW, Sessions.CONTENT_STARRED_URI);

    final FragmentManager fm = getSupportFragmentManager();
    mSessionsFragment = (SessionsFragment) fm.findFragmentByTag("sessions");
    if (mSessionsFragment == null) {
        mSessionsFragment = new SessionsFragment();
        mSessionsFragment.setArguments(intentToFragmentArguments(intent));
        fm.beginTransaction().add(R.id.fragment_sessions, mSessionsFragment, "sessions").commit();
    }

    // Sessions content comes from reused activity
    mTabHost.addTab(mTabHost.newTabSpec(TAG_SESSIONS).setIndicator(buildIndicator(R.string.starred_sessions))
            .setContent(R.id.fragment_sessions));
}

From source file:com.goliathonline.android.kegbot.ui.StarredActivity.java

/**
 * Build and add "vendors" tab.//from   w  ww  . j a  v a 2 s.c  o m
 */
private void setupKegsTab() {
    // TODO: this is very inefficient and messy, clean it up
    FrameLayout fragmentContainer = new FrameLayout(this);
    fragmentContainer.setId(R.id.fragment_kegs);
    fragmentContainer.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer);

    final Intent intent = new Intent(Intent.ACTION_VIEW, Kegs.CONTENT_STARRED_URI);

    final FragmentManager fm = getSupportFragmentManager();

    mKegsFragment = (KegsFragment) fm.findFragmentByTag("kegs");
    if (mKegsFragment == null) {
        mKegsFragment = new KegsFragment();
        mKegsFragment.setArguments(intentToFragmentArguments(intent));
        fm.beginTransaction().add(R.id.fragment_kegs, mKegsFragment, "kegs").commit();
    }

    // Vendors content comes from reused activity
    mTabHost.addTab(mTabHost.newTabSpec(TAG_KEGS).setIndicator(buildIndicator(R.string.starred_kegs))
            .setContent(R.id.fragment_kegs));
}