Android Open Source - AndroidLicensesPage Main Activity






From Project

Back to project page AndroidLicensesPage.

License

The source code is released under:

Apache License

If you think the Android project AndroidLicensesPage listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.androidlicensespageexample;
/*w ww  .ja v a  2  s  . co  m*/
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.View;

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    public void onLicensesClick(View view) {
        /**
         * Display it with no Close button.
         */
        LicensesFragment.displayLicensesFragment(getSupportFragmentManager());

        /**
         * Display it with a Close button.
         */
        //LicensesFragment.displayLicensesFragment(getSupportFragmentManager(), true);

        /**
         * Alternatively, you can display it like a regular DialogFragment.
         */
        // Create & show a licenses fragment just as you would any other DialogFragment.
//        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
//        Fragment prev = getSupportFragmentManager().findFragmentByTag("licensesDialogFragment");
//        if (prev != null) {
//            ft.remove(prev);
//        }
//        ft.addToBackStack(null);
//
//        // Create and show the dialog.
//        // Use LicensesFragment.newInstance(true) to show a Close button.
//        DialogFragment newFragment = LicensesFragment.newInstance();
//        newFragment.show(ft, "licensesDialogFragment");
    }
}




Java Source Code List

com.example.androidlicensespage.LicensesFragment.java
com.example.androidlicensespageexample.LicensesFragment.java
com.example.androidlicensespageexample.MainActivity.java