I am creating an application consists of search widget on action bar which was downloaded from here and i had placed in a my layout.xml but it was showing error on the xml called
The following classes could not be instantiated:The following classes could not be instantiated: - com.milan.searchmenu.persistentsearch.SearchBox (Open Class, Show Error Log) See the Error Log (Window > Show View) for more details. Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse java.lang.NullPointerException By running application also run time null pointer exception occurs can any one tell me how to fix this: This is my 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 is my 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>
}