Home>

is implement a navigation drawer.
I used this site as a premise.
I've made a lot of changes, but I can't resolve the "&draw;_layout","ic_drawer","LOGTAG"symbol.

Program
package The package name will be refrained from this convenience.
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
    private ActionBarDrawerToggle mDrawerToggle;
    private DrawerLayout mDrawer;
    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate (savedInstanceState);
        setContentView (R.layout.activity_main);
        ((Button) findViewById (R.id.drawer_button)). SetOnClickListener (this);
        mDrawer = (DrawerLayout) findViewById (R.id.);
        mDrawerToggle = new ActionBarDrawerToggle (this, mDrawer,
                R.drawable.ic_drawer, R.string.drawer_open,
                R.string.drawer_close) {
            @Override
            public void onDrawerClosed (View drawerView) {
                Log.i (LOGTAG, "onDrawerClosed");
            }
            @Override
            public void onDrawerOpened (View drawerView) {
                Log.i (LOGTAG, "onDrawerOpened");
            }
            @Override
            public void onDrawerSlide (View drawerView, float slideOffset) {
                // The icon animation is processed by the same method in the ActionBarDrawerToggle class.
                // Be careful when overriding.
                super.onDrawerSlide (drawerView, slideOffset);
                Log.i (LOGTAG, "onDrawerSlide:" + slideOffset);
            }
            @Override
            public void onDrawerStateChanged (int newState) {
                // Displayed, closed state: 0
                // Dragging state: 1
                // During the animation after releasing the drag: 2
                Log.i (LOGTAG, "onDrawerStateChanged new state:" + newState);
            }
        };
        mDrawer.setDrawerListener (mDrawerToggle);
        // Enable the UpNavigation icon (the<part next to the icon)
        // Overwrite with R.drawable.drawer in NavigationDrawer
        getActionBar (). setDisplayHomeAsUpEnabled (true);
        // Enable UpNavigation
        getActionBar (). setHomeButtonEnabled (true);
    }
}
  • Answer # 1

    drawer_layout
    I can't find it in the code you presented, but is it a mistake? There is a description ofandroid: id ="@ + id/drawer_layout"in the layout XML in the referenced site. This description makes it available in Java source code.

    ic_drawer
    It is necessary to put "image file by yourself" in the res/drawable folder of the project.

    LOGTAG
    The first argument of each output method of the Log class is to set the character string that becomes the heading when displayed in LogCat.

    private static final String LOGTAG = MainActivity.getClass (). getSimpleName ();


    I think that there are many definitions like this.

    Android programming books and materials are often written for people who have mastered Java to some extent. If you can't read the material based on that, it will be very difficult to read other materials.