title: Navigation Drawer -> activity para fragment
body: <p>I'm in trouble, this code is not working.<br>
  I think my error is in the class, that has the function of the sum in class check1a4. It should be a 'Fragment'?</p>
  
  <p>I tried searching in some tutorials but I did not find a solution. </p>
  
  <p><strong>MainActivity</strong></p>
  
  <pre><code>package com.journaldev.navigationdrawer;  
  import android.support.v4.app.Fragment;  
  import android.support.v4.app.FragmentManager;  
  import android.support.v4.widget.DrawerLayout;  
  import android.support.v7.app.AppCompatActivity;  
  import android.os.Bundle;  
  import android.support.v7.widget.Toolbar;  
  import android.util.Log;  
  import android.view.MenuItem;  
  import android.view.View;  
  import android.widget.AdapterView;  
  import android.widget.ListView;  
  public class MainActivity extends AppCompatActivity {  
  private String[] mNavigationDrawerItemTitles;  
  private DrawerLayout mDrawerLayout;  
  private ListView mDrawerList;  
  Toolbar toolbar;  
  private CharSequence mDrawerTitle;  
  private CharSequence mTitle;  
  android.support.v7.app.ActionBarDrawerToggle mDrawerToggle;  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      mTitle = mDrawerTitle = getTitle();
      mNavigationDrawerItemTitles= getResources().getStringArray(R.array.navigation_drawer_items_array);
      mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
      mDrawerList = (ListView) findViewById(R.id.left_drawer);
  
      setupToolbar();
  
      DataModel[] drawerItem = new DataModel[3];
  
      drawerItem[0] = new DataModel(R.drawable.connect, "Check List (1 a 4)");
      drawerItem[1] = new DataModel(R.drawable.fixtures, "Check List (1 a 19)");
      drawerItem[2] = new DataModel(R.drawable.table, "Sobre a sove");
  
      getSupportActionBar().setDisplayHomeAsUpEnabled(false);
      getSupportActionBar().setHomeButtonEnabled(true);
  
      DrawerItemCustomAdapter adapter = new DrawerItemCustomAdapter(this, R.layout.list_view_item_row, drawerItem);
      mDrawerList.setAdapter(adapter);
      mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
      mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
      mDrawerLayout.setDrawerListener(mDrawerToggle);
      setupDrawerToggle();
  
  
  }
  
  private class DrawerItemClickListener implements ListView.OnItemClickListener {
  
      @Override
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
          selectItem(position);
      }
  
  }
  
  private void selectItem(int position) {
  
      Fragment fragment = null;
  
      switch (position) {
          case 0:
              fragment = new ConnectFragment();
              break;
          case 1:
              fragment = new FixturesFragment();
              break;
          case 2:
              fragment = new TableFragment();
              break;
  
  
          default:
              break;
      }
  
      if (fragment != null) {
          FragmentManager fragmentManager = getSupportFragmentManager();
          fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
  
          mDrawerList.setItemChecked(position, true);
          mDrawerList.setSelection(position);
          setTitle(mNavigationDrawerItemTitles[position]);
          mDrawerLayout.closeDrawer(mDrawerList);
  
      } else {
          Log.e("MainActivity", "Error in creating fragment");
      }
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
  
      if (mDrawerToggle.onOptionsItemSelected(item)) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  
  @Override
  public void setTitle(CharSequence title) {
      mTitle = title;
      getSupportActionBar().setTitle(mTitle);
  }
  
  @Override
  protected void onPostCreate(Bundle savedInstanceState) {
      super.onPostCreate(savedInstanceState);
      mDrawerToggle.syncState();
  }
  
  void setupToolbar(){
      toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
      getSupportActionBar().setDisplayShowHomeEnabled(true);
  }
  
  void setupDrawerToggle(){
      mDrawerToggle = new android.support.v7.app.ActionBarDrawerToggle(this,mDrawerLayout,toolbar,R.string.app_name, R.string.app_name);
      //This is necessary to change the icon of the Drawer Toggle upon state change.
      mDrawerToggle.syncState();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>**java **   </p>
  
  <pre><code>package com.journaldev.navigationdrawer;  
  import android.app.Activity;  
  import android.os.Bundle;  
  import android.support.v7.app.AppCompatActivity;  
  import android.view.View;  
  import android.widget.Button;  
  import android.widget.CheckBox;  
  import android.widget.EditText;  
  import android.app.Activity;  
  import android.os.Bundle;  
  import android.app.AlertDialog;  
  import android.widget.*;  
  import android.view.*;  
  
  public class check1a4 extends Activity {  
  /** Called when the activity is first created. */  
  CheckBox a,s,d,f,g,h,j,k,q,w,e,rr,t,y,u,i,z,x,c,v,b,n,m, aa,ss,dd,ff;  
  EditText resultado;  
  EditText hh,jj,kk,fr,qq,ww,ee;  
  
  @Override
  
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.check1a4);
  
  a = (CheckBox) findViewById(R.id.a);
  s = (CheckBox) findViewById(R.id.s);
  d = (CheckBox) findViewById(R.id.d);
  f = (CheckBox) findViewById(R.id.f);
  g = (CheckBox) findViewById(R.id.g);
  h = (CheckBox) findViewById(R.id.h);
  j = (CheckBox) findViewById(R.id.j);
  k = (CheckBox) findViewById(R.id.k);
  q = (CheckBox) findViewById(R.id.q);
  w = (CheckBox) findViewById(R.id.w);
  e = (CheckBox) findViewById(R.id.e);
  t = (CheckBox) findViewById(R.id.t);
  y = (CheckBox) findViewById(R.id.y);
  u = (CheckBox) findViewById(R.id.u);
  i = (CheckBox) findViewById(R.id.i);
  z = (CheckBox) findViewById(R.id.z);
  x = (CheckBox) findViewById(R.id.x);
  c = (CheckBox) findViewById(R.id.c);
  v = (CheckBox) findViewById(R.id.v);
  b = (CheckBox) findViewById(R.id.b);
  n = (CheckBox) findViewById(R.id.n);
  m = (CheckBox) findViewById(R.id.m);
  rr = (CheckBox) findViewById(R.id.rr);
  aa = (CheckBox) findViewById(R.id.aa);
  ss = (CheckBox) findViewById(R.id.ss);
  dd = (CheckBox) findViewById(R.id.dd);
  ff = (CheckBox) findViewById(R.id.ff);
  
  resultado = (EditText) findViewById(R.id.total);
  
  
  hh = (EditText) findViewById(R.id.hh);
  jj = (EditText) findViewById(R.id.jj);
  kk = (EditText) findViewById(R.id.kk);
  fr = (EditText) findViewById(R.id.fr);
  qq = (EditText) findViewById(R.id.qq);
  ww = (EditText) findViewById(R.id.ww);
  ee = (EditText) findViewById(R.id.ee);
  
  
  
  Button bttotal = (Button) findViewById(R.id.btsomar);
  bttotal.setOnClickListener(new View.OnClickListener() {
  public void onClick(View arg0) {
  
  double total = 0;
  
  if (a.isChecked()) {
  total += 10.0;
              }
   if (s.isChecked()) {
                  total += 5.00;
              }
              if (d.isChecked()) {
                  total += 5.00;
              }
              if (f.isChecked()) {
                  total += 4.00;
              }
  
              if (g.isChecked()) {
                  total += 1.00;
              }
  
              if (h.isChecked()) {
                  total += 1.00;
              }
  
              if (j.isChecked()) {
                  total += 1.00;
              }
  
              if (k.isChecked()) {
                  total += 2.00;
              }
  
              if (q.isChecked()) {
                  total += 1.00;
              }
  
              if (w.isChecked()) {
                  total += 2.00;
              }
              if (e.isChecked()) {
                  total += 2.00;
              }
              if (rr.isChecked()) {
                  total += 1.00;
              }
              if (t.isChecked()) {
                  total += 3.50;
              }
              if (y.isChecked()) {
                  total += 3.50;
              }
              if (u.isChecked()) {
                  total += 1.00;
              }
              if (z.isChecked()) {
                  total += 4.50;
              }
              if (x.isChecked()) {
                  total += 6.00;
              }
              if (c.isChecked()) {
                  total += 4.50;
              }
              if (v.isChecked()) {
                  total += 1.00;
              }
              if (b.isChecked()) {
                  total += 1.00;
              }
  
              if (z.isChecked()) {
                  total += 4.50;
              }
  
              if (n.isChecked()) {
                  total += 6.00;
              }
  
              if (m.isChecked()) {
                  total += 4.00;
              }
              if (aa.isChecked()) {
                  total += 1.50;
              }
              if (ss.isChecked()) {
                  total += 2.00;
              }
              if (dd.isChecked()) {
                  total += 2.50;
              }
              if (ff.isChecked()) {
                  total += 2.00;
              }
  
              double num1  =    Double.parseDouble(hh.getText().toString());
              double num2  =   Double.parseDouble(jj.getText().toString());
              double num3   =   Double.parseDouble(kk.getText().toString());
              double num4  =     Double.parseDouble(qq.getText().toString());
              double num5  =   Double.parseDouble(ww.getText().toString());
              double num6  =    Double.parseDouble(ee.getText().toString());
              double num7  =    Double.parseDouble(fr.getText().toString());
  
  
  
              ////
  
              resultado.setText(String.valueOf(num1+num2+num3+num4+num5+num6+num7+total));
          }
      });
  }}
  </code></pre>
  
  <p><strong>R.layout.check1a</strong></p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/drawer_layout"
  android:layout_width="match_parent"
  android:focusable="false"
  android:layout_height="match_parent" &gt;
  
  &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:focusable="false"
      android:soundEffectsEnabled="false"
      android:splitMotionEvents="false"&gt;
  
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:focusable="false"
          android:addStatesFromChildren="false"
          android:background="@android:color/background_light"
          android:backgroundTint="@android:color/background_dark"
          android:isScrollContainer="true"
          android:orientation="vertical"
          android:weightSum="1"
          tools:isScrollContainer="true"&gt;
  
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Red Lojas 1 a 4"
              android:textAlignment="center"
              android:textSize="18sp"
              android:textStyle="bold" /&gt;
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Disponibilidade Sua loja possui"
              android:textAppearance="@style/TextAppearance.AppCompat"
              android:textSize="18sp"
              android:textStyle="bold" /&gt;
  
          &lt;CheckBox
              android:id="@+id/a"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="CC 2L + CC LT 350 ML" /&gt;
  
          &lt;CheckBox
              android:id="@+id/s"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="CC Ls 1l + CCRefPet 2L" /&gt;
  
          &lt;CheckBox
              android:id="@+id/d"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="CC mini pet 250 ml + Ft Lar. 2l" /&gt;
  
          &lt;CheckBox
              android:id="@+id/f"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Del valle kapo+ TP 200ml ou lt 350ml + Necta 1L + Crystal individual" /&gt;
  
          &lt;CheckBox
              android:id="@+id/g"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="energetico" /&gt;
  
          &lt;CheckBox
              android:id="@+id/h"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Heineken LT 350ml" /&gt;
  
          &lt;CheckBox
              android:id="@+id/j"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Heineken LN 330 ml" /&gt;
  
          &lt;CheckBox
              android:id="@+id/k"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Kaiser Latao  Ou LT 350 ml" /&gt;
  
          &lt;CheckBox
              android:id="@+id/q"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Sol LN" /&gt;
  
          &lt;TextView
              android:layout_width="372dp"
              android:layout_height="wrap_content"
              android:editable="false"
              android:text="Ativação de sua loja"
              android:textAllCaps="false"
              android:textAppearance="@style/TextAppearance.AppCompat"
              android:textIsSelectable="false"
              android:textSize="18sp"
              android:textStyle="bold" /&gt;
  
          &lt;CheckBox
              android:id="@+id/w"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Pop Externo ou entrada da loja" /&gt;
  
          &lt;CheckBox
              android:id="@+id/e"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Pop Interno Familia" /&gt;
  
          &lt;CheckBox
              android:id="@+id/rr"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Presença Refre Retornavel (minimo 3 frentes)" /&gt;
  
          &lt;CheckBox
              android:id="@+id/t"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Presença Refre Retornavel gelado (minimo 3 frentes)" /&gt;
  
          &lt;CheckBox
              android:id="@+id/y"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Rack entrada da loja de retornável" /&gt;
  
          &lt;CheckBox
              android:id="@+id/u"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Rack de suco ou ponto entra (minimo 20 frentes)" /&gt;
  
          &lt;CheckBox
              android:id="@+id/i"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Presença de pack fechado de cerveja na gondola" /&gt;
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Preço correto"
              android:textAppearance="@style/TextAppearance.AppCompat"
              android:textSize="18sp"
              android:textStyle="bold" /&gt;
  
          &lt;CheckBox
              android:id="@+id/z"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="CC Ref Pet 2l + CC LS 1L" /&gt;
  
          &lt;CheckBox
              android:id="@+id/x"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="CC 2l" /&gt;
  
  
          &lt;CheckBox
              android:id="@+id/c"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="CC LT 350 ML" /&gt;
  
  
          &lt;CheckBox
              android:id="@+id/v"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Heineken LN 330 Ml" /&gt;
  
  
          &lt;CheckBox
              android:id="@+id/b"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Cerveja mainstream Lt 350 ml ou Lt 473 ml" /&gt;
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Comunicação de preço"
              android:textAppearance="@style/TextAppearance.AppCompat"
              android:textSize="18sp"
              android:textStyle="bold" /&gt;
  
          &lt;CheckBox
              android:id="@+id/n"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Tudo certo maluco!"
              android:textAppearance="@style/TextAppearance.AppCompat" /&gt;
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Geladeira"
              android:textAppearance="@style/TextAppearance.AppCompat"
              android:textSize="18sp"
              android:textStyle="bold" /&gt;
  
          &lt;CheckBox
              android:id="@+id/m"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="1 porta com refri" /&gt;
  
          &lt;CheckBox
              android:id="@+id/aa"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="1 porta com ncarbs" /&gt;
  
          &lt;CheckBox
              android:id="@+id/ss"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="GDM não invadida" /&gt;
  
          &lt;CheckBox
              android:id="@+id/dd"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Gdm 80% abastecida" /&gt;
  
  
          &lt;CheckBox
              android:id="@+id/ff"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="GDM com 50% de colas" /&gt;
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Sua Sove em loja"
              android:textAppearance="@style/TextAppearance.AppCompat"
              android:textSize="18sp"
              android:textStyle="bold" /&gt;
  
  
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Sovi refrigerante nota: 3.5" /&gt;
  
          &lt;EditText
              android:id="@+id/hh"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:ems="10"
              android:text="0" /&gt;
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Sovi gelado refrigerante nota: 3.0" /&gt;
  
          &lt;EditText
              android:id="@+id/jj"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:ems="10"
              android:text="0" /&gt;
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Sovi refrigerante individual nota:4.5" /&gt;
  
          &lt;EditText
              android:id="@+id/kk"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:ems="10"
              android:text="0" /&gt;
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Sovi Ncarbs nota: 1.0" /&gt;
  
          &lt;EditText
              android:id="@+id/fr"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:ems="10"
              android:text="0" /&gt;
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Sovi Gelado Ncarbs nota: 1.0" /&gt;
  
          &lt;EditText
              android:id="@+id/qq"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:ems="10"
              android:text="0" /&gt;
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Sovi Ncarbs individual nota: 2.0" /&gt;
  
          &lt;EditText
              android:id="@+id/ww"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:ems="10"
              android:text="0" /&gt;
  
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Sovi refrigerante retornavel nota: 7.0" /&gt;
  
          &lt;EditText
              android:id="@+id/ee"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:ems="10"
              android:text="0" /&gt;
  
          &lt;Button
              android:id="@+id/btsomar"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Verificar nota da loja" /&gt;
  
          &lt;EditText
              android:id="@+id/total"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:ems="110"
              android:inputType="textPersonName"
              android:text="0" /&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p></p>