Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android-导航抽屉不启动到其他活动_Java_Android - Fatal编程技术网

Java Android-导航抽屉不启动到其他活动

Java Android-导航抽屉不启动到其他活动,java,android,Java,Android,以下是当我单击导航抽屉上的菜单项时出现的错误:W/PathParser:点之间的距离太远4.000000596046461 当我点击物品时,抽屉不会进入下一个活动。我需要知道我怎样才能解决这个问题。我认为你不需要抽屉里的xml,因为里面没有图像等等。这个抽屉就是不能正常工作 public class dashboard extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener

以下是当我单击导航抽屉上的菜单项时出现的错误:W/PathParser:点之间的距离太远4.000000596046461

当我点击物品时,抽屉不会进入下一个活动。我需要知道我怎样才能解决这个问题。我认为你不需要抽屉里的xml,因为里面没有图像等等。这个抽屉就是不能正常工作

public class dashboard extends AppCompatActivity
    implements NavigationView.OnNavigationItemSelectedListener {
ViewHolder holder;

@Override
public void onOptionsMenuClosed(Menu menu) {
    super.onOptionsMenuClosed(menu);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dashboard);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    holder = new ViewHolder();
    holder.allRecipes = (ImageView) findViewById(R.id.dash_recipes);
    holder.breakfast = (ImageView) findViewById(R.id.dash_breakfest);
    holder.lunch = (ImageView) findViewById(R.id.dash_lunch);
    holder.dinner = (ImageView) findViewById(R.id.dash_dinner);
    holder.drinks = (ImageView) findViewById(R.id.dash_drinks);
    holder.vegetarian = (ImageView) findViewById(R.id.dash_vegetarian);
}

public void onClick(View v)
{
    switch(v.getId())
    {
        case R.id.dash_recipes:
            // list of top recipes
            break;
        case R.id.dash_breakfest:
            // breakfast based on health profile
            break;
        case R.id.dash_lunch:
            break;
        case R.id.dash_dinner:
            break;
        case R.id.dash_drinks:
            break;
        case R.id.dash_vegetarian:
            break;
        default:
            break;
    }



}
@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}

@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_dashboard) {
        // Handle the action
    }
    else if (id == R.id.nav_shopping_list) {
        Intent i = new Intent(dashboard.this, shopping_list.class);
        startActivity(i);
    }
    else if (id == R.id.nav_deals) {
        Intent i = new Intent(dashboard.this, deals.class);
        startActivity(i);
    }
    else if (id == R.id.nav_recipes) {
        Intent i = new Intent(dashboard.this, recipes.class);
        startActivity(i);
    }
    else if (id == R.id.nav_agenda) {
        Intent i = new Intent(dashboard.this, agenda.class);
        startActivity(i);

    }
    else if (id == R.id.nav_scan) {
        /*
        Intent i = new Intent(dashboard.this, scan.class);
        startActivity(i);
        */
    }
    else if (id == R.id.nav_health_profile) {
        Intent i = new Intent(dashboard.this, health_profile.class);
        startActivity(i);
    }
    else if (id == R.id.nav_settings) {
        Intent i = new Intent(dashboard.this, settings.class);
        startActivity(i);
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
class ViewHolder
{
    ImageView allRecipes;
    ImageView breakfast;
    ImageView lunch;
    ImageView dinner;
    ImageView drinks;
    ImageView vegetarian;
  }
}