Nath Ward
Nath Ward

Reputation: 61

Android material drawer library issue

Here is my code, the part where it says 'DrawerView drawer'is my issue as you can see here The part above let me import the support.v4.widget.DrawerLayout but here there's nothing that i can import.

I'm still moderately new to android dev, so sorry if i'm doing anything wrong here

package com.nath.thecompletembguide;

import com.kskkbys.rate.RateThisApp;
import com.startapp.android.publish.SDKAdPreferences;
import com.startapp.android.publish.SDKAdPreferences.Gender;
import com.startapp.android.publish.StartAppSDK;

import android.net.Uri;
import android.os.Bundle;
import android.content.Intent;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

public class MainActivity extends ActionBarActivity {



    @Override
    protected void onStart() {
        super.onStart();
        // Monitor launch times and interval from installation
        RateThisApp.onStart(this);
        // If the criteria is satisfied, "Rate this app" dialog will be shown
        RateThisApp.showRateDialogIfNeeded(this);
    }

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        StartAppSDK.init(this, "105864370", "207677226", new SDKAdPreferences().setAge(10).setGender(Gender.MALE), false);
        setContentView(R.layout.activity_main); 

        DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
        DrawerView drawer = (DrawerView) findViewById(R.id.drawer);

        }





@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 boolean onOptionsItemSelected(MenuItem item) 
{
    if(android.R.id.home == item.getItemId()){
        finish();

    return super.onOptionsItemSelected(item);
    }

    switch (item.getItemId()) 
    {
        case R.id.action_upgrade:
            Intent launchNewIntent = new Intent("android.intent.action.VIEW", Uri.parse("https://play.google.com/store/apps/details?id=com.nath.thecompletembguidepro"));
            startActivity(launchNewIntent);
            return true;
        case R.id.action_about:
            Intent launchNewIntent3 = new Intent(MainActivity.this, MainActivity.class);
            startActivity(launchNewIntent3);
            return true;
        case R.id.action_credits:
            Intent launchNewIntent1 = new Intent(MainActivity.this,MainActivity.class);
            startActivityForResult(launchNewIntent1, 0);
            return true;
        case R.id.action_changelogs:
            Intent launchNewIntent2 = new Intent("android.intent.action.VIEW", Uri.parse("http://nathcraft.com"));
            startActivity(launchNewIntent2);
            Toast.makeText(MainActivity.this, "Requires Network Connection", Toast.LENGTH_SHORT).show();
            return true;
            default:
                return super.onOptionsItemSelected(item);
            }}}

Upvotes: 1

Views: 385

Answers (3)

prom85
prom85

Reputation: 17798

Many libraries (prpbably due to android studio...) use the java folder as their src folder... Moving all code in the library in eclipse from the 'java' folder to the src folder, cleaning and rebuilding the library afterwards, and then refresh your own project, should solve the problem...

Upvotes: 1

SWAppDev
SWAppDev

Reputation: 248

i'm using it in Eclipse too : i have made a copy of all Heinrich's packages and their layout, values... in my own project and it seems to work fine so far. Well i have a problem i'm not the only to have: the profile doesn't show, only the items

Upvotes: 0

Alchete
Alchete

Reputation: 1649

Your imports look fine as far as I can see. DrawerView isn't a thing. :)

Unfortunately, there's a lot of boilerplate code needed to get the navigation drawer up and working. But, fortunately, there are lots of examples.

A good reference is the Google IO app, which was written by Roman Nurik and team, who have also made all the source code available.

Of interest to you will be the layout XML resources and the source code:

Layout XML (scroll down to "navdrawer") https://github.com/google/iosched/tree/dfaf8b83ad1b3e7c8d1af0b08d59caf4223e0b95/android/src/main/res/layout

Source code: https://github.com/google/iosched/blob/dfaf8b83ad1b3e7c8d1af0b08d59caf4223e0b95/android/src/main/java/com/google/samples/apps/iosched/ui/BaseActivity.java

To download the Application: https://play.google.com/store/apps/details?id=com.google.samples.apps.iosched

Upvotes: 0

Related Questions