SOFARI HASSANE

SOFARI HASSANE

  • NA
  • 237
  • 21.7k

App has stopped

Mar 29 2018 9:31 AM
Hi!
I'm looking for help with this error!
 
activity.xml
  1. android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:app="http://schemas.android.com/apk/res-auto"  
  3.     xmlns:tools="http://schemas.android.com/tools"  
  4.     android:layout_width="match_parent"  
  5.     android:layout_height="match_parent"  
  6.     tools:context="com.example.di_prn.ganigazapp.ArticlesDetails">  
  7.       
  8.       
  9.     <android.support.design.widget.AppBarLayout  
  10.         android:id="@+id/app_bar_layout"  
  11.         android:layout_width="match_parent"  
  12.         android:layout_height="wrap_content"  
  13.         android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"  
  14.         android:fitsSystemWindows="true">  
  15.   
  16.         <android.support.design.widget.CollapsingToolbarLayout  
  17.             android:id="@+id/collapsing"  
  18.             android:layout_width="match_parent"  
  19.             android:layout_height="350dp"  
  20.               android:fitsSystemWindows="true"  
  21.             app:layout_scrollFlags="scroll|exitUntilCollapsed"  
  22.             app:contentScrim="#0e0d0e"  
  23.             app:expandedTitleTextAppearance="@android:color/transparent"  
  24.             >  
  25.             <ImageView  
  26.                 android:id="@+id/img_article"  
  27.                 android:layout_width="match_parent"  
  28.                 android:layout_height="match_parent"  
  29.                 android:contentDescription="@null"  
  30.                 android:scaleType="centerCrop"  
  31.                 app:layout_collapseMode="parallax"/>  
  32.               
  33.             <android.support.v7.widget.Toolbar  
  34.                 android:id="@+id/toolbar"  
  35.   
  36.                 android:layout_width="match_parent"  
  37.                 android:layout_height="?attr/actionBarSize"  
  38.                  app:popupTheme="@style/AlertDialog.AppCompat.Light"  
  39.                   app:layout_collapseMode="parallax"  
  40.                 />  
  41.   
  42.         </android.support.design.widget.CollapsingToolbarLayout>  
  43.   
  44.     </android.support.design.widget.AppBarLayout>  
  45.   
  46.     <android.support.design.widget.FloatingActionButton  
  47.         android:id="@+id/btnCart"  
  48.         android:src="@drawable/ic_shopping_cart_black_24dp"  
  49.         app:backgroundTint="@android:color/white"  
  50.         android:layout_width="match_parent"  
  51.         android:layout_height="wrap_content"  
  52.         android:elevation="6dp"  
  53.         app:pressedTranslationZ="12dp"  
  54.         app:layout_anchor="@id/app_bar_layout"  
  55.         app:layout_anchorGravity="bottom|right|end"  
  56.         app:useCompatPadding="true"  
  57.         />  
  58.   
  59.     <android.support.v4.widget.NestedScrollView  
  60.         android:id="@+id/nestedScrollView"  
  61.         android:clipToPadding="false"  
  62.         android:layout_width="match_parent"  
  63.         android:layout_height="match_parent"  
  64.         app:layout_behavior="@string/appbar_scrolling_view_behavior"  
  65.         >  
  66.   
  67.         <LinearLayout  
  68.             android:orientation="vertical"  
  69.             android:layout_width="match_parent"  
  70.             android:layout_height="match_parent">  
  71.   
  72.            <android.support.v7.widget.CardView  
  73.                android:layout_width="match_parent"  
  74.                android:layout_height="wrap_content"  
  75.                app:cardElevation="5dp"  
  76.                app:cardUseCompatPadding="true"  
  77.                >  
  78.   
  79.                <LinearLayout  
  80.                    android:orientation="vertical"  
  81.                    android:layout_width="match_parent"  
  82.                    android:layout_height="wrap_content">  
  83.   
  84.                    <TextView  
  85.                        android:id="@+id/article_name"  
  86.                        android:layout_marginTop="8dp"  
  87.                        android:padding="12dp"  
  88.                        android:text="Nom de l'Article"  
  89.                        android:textColor="@color/colorPrimary"  
  90.                        android:textSize="20sp"  
  91.                        android:textStyle="bold"  
  92.                        android:layout_width="wrap_content"  
  93.                        android:layout_height="wrap_content" />  
  94.   
  95.                 <LinearLayout  
  96.                     android:id="@+id/layout_price"  
  97.                     android:orientation="horizontal"  
  98.                     android:layout_width="match_parent"  
  99.                     android:layout_height="wrap_content">  
  100.   
  101.                     <ImageView  
  102.                         android:src="@drawable/ic_money"  
  103.                         android:layout_weight="1"  
  104.                         android:layout_width="0dp"  
  105.                         android:layout_height="wrap_content" />  
  106.   
  107.                     <TextView  
  108.                         android:id="@+id/article_price"  
  109.                         android:text="1,000"  
  110.                         android:textColor="@color/colorPrimary"  
  111.                         android:textSize="18sp"  
  112.                         android:textStyle="bold"  
  113.                         android:layout_width="0dp"  
  114.                         android:layout_weight="9"  
  115.                         android:layout_height="wrap_content" />  
  116.   
  117.                 </LinearLayout>  
  118.   
  119.                 <com.cepheuen.elegantnumberbutton.view.ElegantNumberButton  
  120.                     android:layout_width="100dp"  
  121.                     android:layout_height="30dp"  
  122.                      android:id="@+id/number_button"  
  123.                     android:layout_marginTop="8dp"  
  124.                     android:layout_marginLeft="8dp"  
  125.                     android:layout_marginBottom="18dp"  
  126.                     app:textSize="8sp"  
  127.                     app:backGroundColor="@color/colorPrimary"  
  128.                     app:initialNumber="1"  
  129.                     app:finalNumber="10"  
  130.                     />  
  131.   
  132.   
  133.                </LinearLayout>  
  134.   
  135.   
  136.            </android.support.v7.widget.CardView>  
  137.   
  138.             <android.support.v7.widget.CardView  
  139.                 app:cardElevation="5dp"  
  140.                 app:cardUseCompatPadding="true"  
  141.                 android:layout_width="match_parent"  
  142.                 android:layout_height="wrap_content">  
  143.   
  144.                 <TextView  
  145.                     android:id="@+id/article_description"  
  146.                     android:layout_marginTop="12dp"  
  147.                     android:lineSpacingMultiplier="1.5"  
  148.                     android:padding="12dp"  
  149.                     android:text="Détails Article"  
  150.                     android:textColor="@android:color/black"  
  151.                     android:textSize="14sp"  
  152.                     android:layout_width="wrap_content"  
  153.                     android:layout_height="wrap_content" />  
  154.   
  155.   
  156.             </android.support.v7.widget.CardView>  
  157.   
  158.         </LinearLayout>  
  159.   
  160.   
  161.   
  162.     </android.support.v4.widget.NestedScrollView>  
  163.   
  164.   
  165.   
  166. </android.support.design.widget.CoordinatorLayout>  
Home.java
  1. public class Home extends AppCompatActivity  
  2.         implements NavigationView.OnNavigationItemSelectedListener {  
  3.   
  4.     FirebaseDatabase database;  
  5.     DatabaseReference category;  
  6.   
  7.     TextView txtFullName;  
  8.   
  9.     RecyclerView recycler_menu;  
  10.     RecyclerView.LayoutManager layoutManager;  
  11.   
  12.     FirebaseRecyclerAdapter<Category,MenuViewHolder> adapter;  
  13.   
  14.     @Override  
  15.     protected void onCreate(Bundle savedInstanceState) {  
  16.   
  17.         setContentView(R.layout.activity_home);  
  18.         super.onCreate(savedInstanceState);  
  19.   
  20.         Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);  
  21.         toolbar.setTitle("Menu");  
  22.         setSupportActionBar(toolbar);  
  23.   
  24.   
  25.         database = FirebaseDatabase.getInstance();  
  26.         category = database.getReference("Category");  
  27.   
  28.   
  29.         FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);  
  30.         fab.setOnClickListener(new View.OnClickListener() {  
  31.             @Override  
  32.             public void onClick(View view) {  
  33.                 Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)  
  34.                         .setAction("Action"null).show();  
  35.             }  
  36.         });  
  37.   
  38.         DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);  
  39.         ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(  
  40.                 this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);  
  41.         drawer.addDrawerListener(toggle);  
  42.         toggle.syncState();  
  43.   
  44.         NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);  
  45.         navigationView.setNavigationItemSelectedListener(this);  
  46.   
  47.   
  48.         View headerView = navigationView.getHeaderView(0);  
  49.         txtFullName = headerView.findViewById(R.id.txtFullName);  
  50.         txtFullName.setText(Common.currentUser.getName());  
  51.   
  52.      recycler_menu = (RecyclerView)findViewById(R.id.recycler_menu);  
  53.      recycler_menu.setHasFixedSize(true);  
  54.      layoutManager = new LinearLayoutManager(this);  
  55.      recycler_menu.setLayoutManager(layoutManager);  
  56.   
  57.       loadMenu();  
  58.   
  59.     }  
  60.   
  61.     private void loadMenu() {  
  62.          adapter = new FirebaseRecyclerAdapter<Category, MenuViewHolder>(Category.class,R.layout.menu_item,MenuViewHolder.class,category) {  
  63.             @Override  
  64.             protected void populateViewHolder(MenuViewHolder viewHolder, Category model, int position) {  
  65.              viewHolder.txtMenuName.setText(model.getName());  
  66.                 Picasso.with(getBaseContext()).load(model.getImage())  
  67.                         .into(viewHolder.imageView);  
  68.                 final Category clickitem = model;  
  69.                 viewHolder.setItemClickListener(new ItemClickListener() {  
  70.                     @Override  
  71.                     public void onClick(View view, int position, boolean isLongClick) {  
  72.                     Intent articleList = new Intent(Home.this,ArticlesListe.class);  
  73.                     articleList.putExtra("CategoryId",adapter.getRef(position).getKey());  
  74.                     startActivity(articleList);  
  75.                     }  
  76.                 });  
  77.             }  
  78.         };  
  79.   
  80.         recycler_menu.setAdapter(adapter);  
  81.     }  
  82.   
  83.     @Override  
  84.     public void onBackPressed() {  
  85.         DrawerLayout drawer = findViewById(R.id.drawer_layout);  
  86.         if (drawer.isDrawerOpen(GravityCompat.START)) {  
  87.             drawer.closeDrawer(GravityCompat.START);  
  88.         } else {  
  89.             super.onBackPressed();  
  90.         }  
  91.     }  
  92.   
  93.     @Override  
  94.     public boolean onCreateOptionsMenu(Menu menu) {  
  95.         // Inflate the menu; this adds items to the action bar if it is present.  
  96.         getMenuInflater().inflate(R.menu.home, menu);  
  97.         return true;  
  98.     }  
  99.   
  100.     @Override  
  101.     public boolean onOptionsItemSelected(MenuItem item) {  
  102.   
  103.   
  104.         return super.onOptionsItemSelected(item);  
  105.     }  
  106.   
  107.     @SuppressWarnings("StatementWithEmptyBody")  
  108.     @Override  
  109.     public boolean onNavigationItemSelected(MenuItem item) {  
  110.         // Handle navigation view item clicks here.  
  111.         int id = item.getItemId();  
  112.   
  113.         if (id == R.id.nav_menu) {  
  114.             // Handle the camera action  
  115.         } else if (id == R.id.nav_cart) {  
  116.   
  117.         } else if (id == R.id.nav_orders) {  
  118.   
  119.         } else if (id == R.id.nav_log_out) {  
  120.   
  121.         }  
  122.   
  123.         DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);  
  124.         drawer.closeDrawer(GravityCompat.START);  
  125.         return true;  
  126.     }  
logcat
  1. 03-29 10:30:41.311 1684-1727/com.example.di_prn.ganigazapp E/EGL_emulation: tid 1727: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)  
  2. 03-29 10:30:43.240 1684-1727/com.example.di_prn.ganigazapp E/EGL_emulation: tid 1727: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)  
  3. 03-29 10:30:47.852 1684-1684/com.example.di_prn.ganigazapp E/AndroidRuntime: FATAL EXCEPTION: main  
  4.                                                                              Process: com.example.di_prn.ganigazapp, PID: 1684  
  5.                                                                              java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.di_prn.ganigazapp/com.example.di_prn.ganigazapp.Home}: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.  
  6.                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)  
  7.                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)  
  8.                                                                                  at android.app.ActivityThread.-wrap12(ActivityThread.java)  
  9.                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)  
  10.                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102)  
  11.                                                                                  at android.os.Looper.loop(Looper.java:154)  
  12.                                                                                  at android.app.ActivityThread.main(ActivityThread.java:6119)  
  13.                                                                                  at java.lang.reflect.Method.invoke(Native Method)  
  14.                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)  
  15.                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)  
  16.                                                                               Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.  
  17.                                                                                  at android.support.v7.app.AppCompatDelegateImplV9.setSupportActionBar(AppCompatDelegateImplV9.java:201)  
  18.                                                                                  at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:129)  
  19.                                                                                  at com.example.di_prn.ganigazapp.Home.onCreate(Home.java:51)  
  20.                                                                                  at android.app.Activity.performCreate(Activity.java:6679)  
  21.                                                                                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)  
  22.                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)  
  23.                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)   
  24.                                                                                  at android.app.ActivityThread.-wrap12(ActivityThread.java)   
  25.                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)   
  26.                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102)   
  27.                                                                                  at android.os.Looper.loop(Looper.java:154)   
  28.                                                                                  at android.app.ActivityThread.main(ActivityThread.java:6119)   
  29.                                                                                  at java.lang.reflect.Method.invoke(Native Method)   
  30.                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)   
  31.                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)   
 
 

Answers (3)