Saturday, May 28, 2016


Java files and their corresponding XML layout files:

  • MainActivity.java
    • nav_drawer_base.xml
      • This file contains the xml for Navigation drawer and menu layout. It also contains the FrameLayout used as the canvas for the app content.

  • BaseFragment.java
  • MainFragment.java
    • main_frag.xml
      • This layout file is wrapped in a CoordinatorLayout
      • Toolbar to replace the default ActionBar, 
      • TabLayout bar for tabbing, and a 
      • ViewPager element to support 

How to get the main_fragment layout swapped into the container view slot:
How to get the Navigation Drawer working:
DrawerLayout drawer = listener.getDrawer();ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(ACA, drawer, toolbar, R.string.navigation_drawer_open,                R.string.navigation_drawer_close);
toggle.syncState();
drawer.setDrawerListener(toggle);
navigationView.setNavigationItemSelectedListener(this);
//swap home bar and give it a title
ACA.setSupportActionBar(toolbar);ACA.getSupportActionBar().setTitle("WASSUP");

Monday, May 16, 2016

User Dialog Fragment


Here are some important learnings for displaying a user dialog fragment. Steps to create:

  1. Create a new layout file for the dialog.
  2. Create a new Java class to inflate the fragment. This should extend the Android system DialogFragment class.
  3. Create reference in the main activity to inflate the dialog
To accomplish this, I simply created a new method in MainActivity.java called "showDialog()".

public void showDialog(View v){
        FragmentManager manager = getFragmentManager();
        FragmentDialog addDialog = new FragmentDialog();
        addDialog.show(manager, "addDialog");
}

You can see I am making use of two new objects:

  1. FragmentDialog --> This is the class I created to inflate the new xml layout
  2. FragmentManager --> Android system object used as an interface for dealing with fragments

Helpful resources:

Sunday, May 15, 2016

Android App 2 Goals

I finished my free GDG Android class this week and I'm starting up a little project to help teach me some Android programming building blocks. After being hand-held through development of a "Tic Tac Toe" game, I'm still a bit deficient when it comes to some important development principles. Here's my list of learning goals for this project - all of which I hope to make a separate post explaining how I've accomplished them:

  1. Loading ListView data with Adapters
  2. ListView item adds, selection, edit, delete
  3. Crawl Android contacts, birthdays, etc
  4. Fragments
  5. Context objects
  6. Context Menus