это мой xml-файл навигации. Я пытаюсь открыть два вида навигации с одной стороны, но получаю сообщение об ошибке, указывающее, что java.lang.IllegalStateException: дочерний ящик имеет абсолютную гравитацию ВЛЕВО, но у этого DrawerLayout уже есть вид ящика вдоль этого края android.support.v4.widget.DrawerLayout.onMeasure (DrawerLayout.java:1074)
Feedpost.java
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;
import com.example.kaush.scoreboard.R;
public class FeedPost extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
DrawerLayout drawer;
TextView tvSwipDescription;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_feed__post);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
//----------HIDE TOGGLE HAMBURGER ICON--------------
toggle.setDrawerIndicatorEnabled(false);
toggle.syncState();
NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
NavigationView navigationView1 = findViewById(R.id.nav_right_view);
navigationView1.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle Right navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_settings) {
Toast.makeText(FeedPost.this, "Right Drawer - Settings", Toast.LENGTH_SHORT).show();
} else if (id == R.id.nav_logout) {
Toast.makeText(FeedPost.this, "Right Drawer - Logout", Toast.LENGTH_SHORT).show();
} else if (id == R.id.nav_help) {
Toast.makeText(FeedPost.this, "Right Drawer - Help", Toast.LENGTH_SHORT).show();
} else if (id == R.id.nav_about) {
Toast.makeText(FeedPost.this, "Right Drawer - About", Toast.LENGTH_SHORT).show();
}
drawer.closeDrawer(GravityCompat.END); /*Important Line*/
return true;
}
});
}
// private void initializeView() {
//
// tvSwipDescription=(TextView) findViewById(R.id.tvSwipDescription);
// }
@Override
public void onBackPressed() {
DrawerLayout drawer = findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else
if (drawer.isDrawerOpen(GravityCompat.END)) { /*Closes the Appropriate Drawer*/
drawer.closeDrawer(GravityCompat.END);
}
else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.feed__post, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_camera) {
// Handle the camera action
} else if (id == R.id.nav_gallery) {
} else if (id == R.id.nav_slideshow) {
} else if (id == R.id.nav_manage) {
} else if (id == R.id.nav_share) {
} else if (id == R.id.nav_send) {
}
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.END);
return true;
}
}
activity_feed_post.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="1"
android:fitsSystemWindows="true"
android:layout_gravity="right|center"
tools:openDrawer="start">
<include
layout="@layout/app_bar_feed__post"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:paddingBottom="96dp"
android:clipToPadding="false"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_feed__post"
app:menu="@menu/activity_feed__post_drawer" >
</android.support.design.widget.NavigationView>
<android.support.design.widget.NavigationView
android:id="@+id/nav_right_view"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_feed__post"
app:menu="@menu/activity_main_drawer_right" />
</android.support.v4.widget.DrawerLayout>