How to fix The following classes could not be instantiated in android -
i creating application consists of search widget on action bar downloaded here , had placed in layout.xml showing error on xml called
the following classes not instantiated:the following classes not instantiated: - com.milan.searchmenu.persistentsearch.searchbox (open class, show error log) see error log (window > show view) more details. tip: use view.isineditmode() in custom views skip code when shown in eclipse java.lang.nullpointerexception running application run time null pointer exception occurs can 1 tell me how fix this: activity:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.manual); actionbar actionbar; actionbar = getactionbar(); search = (searchbox) findviewbyid(r.id.searchbox); search.enablevoicerecognition(this); for(int x = 0; x < 10; x++){ com.milan.searchmenu.persistentsearch.searchresult option = new searchresult("result " + integer.tostring(x), getresources().getdrawable(r.drawable.ic_history)); search.addsearchable(option); } search.setmenulistener(new menulistener(){ @override public void onmenuclick() { //hamburger has been clicked toast.maketext(manual.this, "menu click", toast.length_long).show(); } }); search.setsearchlistener(new searchlistener() { @override public void onsearchtermchanged() { // todo auto-generated method stub } @override public void onsearchopened() { // todo auto-generated method stub } @override public void onsearchclosed() { // todo auto-generated method stub } @override public void onsearchcleared() { // todo auto-generated method stub } @override public void onsearch(string result) { toast.maketext(manual.this, result +" searched", toast.length_long).show(); } });
this xml:
<relativelayout android:id="@+id/relative_layout" android:layout_width="wrap_content" android:layout_height="51dp" android:layout_alignparentleft="true" android:layout_alignparentright="true" android:layout_alignparenttop="true" android:background="#673ab7"> <com.milan.searchmenu.persistentsearch.searchbox android:layout_width="wrap_content" android:id="@+id/searchbox" android:layout_height="wrap_content"> </com.milan.searchmenu.persistentsearch.searchbox> </relativelayout> <android.support.v4.view.viewpager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/pager_sliding_tab_strip"> </android.support.v4.view.viewpager> <com.milan.tabs.pagerslidingstrip.pagerslidingtabstrip android:id="@+id/pager_sliding_tab_strip" android:layout_width="match_parent" android:layout_height="50dp" android:layout_alignparentleft="true" android:layout_below="@+id/relative_layout" android:textsize="15dp" app:pstsshouldexpand="true" app:pstsdividercolor="#b39ddb" app:pstsindicatorheight="45dp" android:background="#673ab7" app:pstsindicatorcolor="#ffffff"> </com.milan.tabs.pagerslidingstrip.pagerslidingtabstrip> }
you need add downloaded library dependency of module. in android studio following
- place library in project somewhere.
- right click on library , select "add library"
- choose main module: either called app or mobile.
- rebuild , should work
Comments
Post a Comment