java - MainActivity is not public -
i getting weird error in androidmanifest.xml file saying "mainactivity not public. validate resource reference inside android xml files." not know how solve error. can me here?
androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.pixalstudio.javaclasses" > <uses-permission android:name="android.permission.access_network_state" > </uses-permission> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".mainactivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".what_is_java" android:label="@string/title_activity_what_is_java" > </activity> </application> </manifest>
mainactivity.java
package com.pixalstudio.javaclasses; import android.content.intent; import android.content.res.configuration; import android.net.connectivitymanager; import android.net.networkinfo; import android.os.bundle; import android.support.v4.widget.drawerlayout; import android.support.v7.app.actionbaractivity; import android.support.v7.app.actionbardrawertoggle; import android.support.v7.widget.toolbar; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.listview; import android.widget.toast; class mainactivity extends actionbaractivity implements adapterview.onitemclicklistener { private toolbar toolbar; listview mdrawerlist; drawerlayout mdrawerlayout; actionbardrawertoggle mdrawertoggle; string[] mdrawerlistitems; string[] mdrawerlistitems2; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); connectivitymanager cmanager = (connectivitymanager) getsystemservice(this.connectivity_service); networkinfo ninfo = cmanager.getactivenetworkinfo(); if (ninfo != null && ninfo.isconnected()) { toast.maketext(this, "newtwrok available", toast.length_long).show(); } else { toast.maketext(this, "network not available", toast.length_long).show(); } toolbar = (toolbar) findviewbyid(r.id.app_bar); setsupportactionbar(toolbar); layoutinflater inflater = getlayoutinflater(); mdrawerlayout = (drawerlayout) findviewbyid(r.id.drawerlayout); mdrawerlist = (listview) findviewbyid(r.id.drawerlist); mdrawerlistitems = getresources().getstringarray(r.array.drawer_list); viewgroup header_news = (viewgroup) inflater.inflate(r.layout.nav_header, mdrawerlist, false); mdrawerlist.addheaderview(header_news, null, false); mdrawerlist.setadapter(new arrayadapter<string>(this, android.r.layout.simple_list_item_1, mdrawerlistitems)); mdrawerlist.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { if (position == 1) { intent = new intent(mainactivity.this, what_is_java.class); startactivity(i); } mdrawerlayout.closedrawer(mdrawerlist); } }); mdrawertoggle = new actionbardrawertoggle(this, mdrawerlayout, toolbar, r.string.drawer_open, r.string.drawer_close) { @override public void ondrawerclosed(view drawerview) { super.ondrawerclosed(drawerview); invalidateoptionsmenu(); syncstate(); } @override public void ondraweropened(view drawerview) { super.ondraweropened(drawerview); invalidateoptionsmenu(); syncstate(); } }; mdrawerlayout.setdrawerlistener(mdrawertoggle); setsupportactionbar(toolbar); getsupportactionbar().setdisplayhomeasupenabled(true); getsupportactionbar().sethomebuttonenabled(true); mdrawertoggle.syncstate(); } @override public void onpostcreate(bundle savedinstancestate) { super.onpostcreate(savedinstancestate); mdrawertoggle.syncstate(); } @override public void onconfigurationchanged(configuration newconfig) { super.onconfigurationchanged(newconfig); mdrawertoggle.syncstate(); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case android.r.id.home: { if (mdrawerlayout.isdraweropen(mdrawerlist)) { mdrawerlayout.closedrawer(mdrawerlist); } else { mdrawerlayout.opendrawer(mdrawerlist); } return true; } default: return super.onoptionsitemselected(item); } } @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { if (position == 2) { intent = new intent(this, what_is_java.class); startactivity(i); } mdrawerlayout.closedrawer(mdrawerlist); } }
activity_main.xml
<linearlayout 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:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include android:id="@+id/app_bar" layout="@layout/app_bar"> </include> <android.support.v4.widget.drawerlayout android:id="@+id/drawerlayout" android:layout_width="match_parent" android:layout_height="match_parent"> <framelayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent"> </framelayout> <listview android:id="@+id/drawerlist" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:background="#ce93d8"> </listview> </android.support.v4.widget.drawerlayout> </linearlayout>
change class mainactivity [...]
public class mainactivity [...]
in mainactivity.java
Comments
Post a Comment