Activity1
private Cursor model = null;
private ClientAdapter adapter = null;
private ClientHelper helper = null;
private SharedPreferences prefs = null;
private ArrayAdapter<String> adapters;
private ArrayAdapter<String> adaptera;
private String[] available_locations;
private String[] selected_locations;
private ListView list1;
private ListView list2;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.locations);
list1 = (ListView) findViewById(R.id.available_locations);
list2 = (ListView) findViewById(R.id.selected_locations);
available_locations = getIntent().getStringExtra("List");
.....
Activity 2
....
public String getID(Cursor c) {
return (c.getString(0));
}
public String getclientName(Cursor c) {
return (c.getString(1));
}
public String getAddress(Cursor c) {
return (c.getString(2));
}
public String getTelephone(Cursor c) {
return (c.getString(3));
}
public String getCuisineType(Cursor c) {
return (c.getString(4));
}
public double getLatitude(Cursor c) {
return (c.getDouble(5));
}
public double getLongitude(Cursor c) {
return (c.getDouble(6));
}
public ArrayList<String> getclient;
getclient.add("clientName");
getclient.add("Address");
getclient.add("Telephone");
getclient.add("cuisineType");
getclient.add("lat");
getclient.add("lon");
public Intent intenti;
intenti = new Intent(ClientHelper.this, SetDestination.class);
intenti.putExtra("List", getclient);
startactivity(intenti);
How do I pass information from Activity2 to Activity1?
I want to do a Listview where I can select clients from the list that I have already added (hence two activity, list1 and list2, in activity1)
Use can use the Bundle to pass the data from one activity to other.
First make the object parcelable.You can do that using the plugin of Parcelable in android studio.
Example.
Intent intent=new Intent(getActivity(),targetclassname.class);
HomeScreenData homeScreenData=new HomeScreenData();//Pojo class
intent.putExtra("categorydesc",homeScreenData);
startActivity(intent);
{
//Pojo Class`enter code here`
public class HomeScreenData implements Parcelable {
private String imagePath;
private String imageTitle;
public String getImagePath() {
return imagePath;
}
public void setImagePath(String imagePath) {
this.imagePath = imagePath;
}
public String getImageTitle() {
return imageTitle;
}
public void setImageTitle(String imageTitle) {
this.imageTitle = imageTitle;
}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.imagePath);
dest.writeString(this.imageTitle);
}
public HomeScreenData() {
}
protected HomeScreenData(Parcel in) {
this.imagePath = in.readString();
this.imageTitle = in.readString();
}
public static final Parcelable.Creator<HomeScreenData> CREATOR = new Parcelable.Creator<HomeScreenData>() {
public HomeScreenData createFromParcel(Parcel source) {
return new HomeScreenData(source);
}
public HomeScreenData[] newArray(int size) {
return new HomeScreenData[size];
}
};
}
Related
so im trying to get recyclerview data list added and send it to ion lib when i use method below i only get one element as ill have to change string inside for() to String fav =null ouside of for() and log.d only shows the last result. i need get all so i can send to senddata() to ion lib
FavModelClass
private String fav;
private String user_id;
public FavModelClass(String fav, String user_id) {
this.fav = fav;
this.user_id = user_id;
}
public String getFav() {
return fav;
}
public void setFav(String fav) {
this.fav = fav;
}
public String getUser_id() {
return user_id;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
}
}
adapter
public class FavAdapter extends
RecyclerView.Adapter<FavAdapter .MyViewHolder> {
private List<FavModelClass> favModelClassList;
private Context beddingContext;
public FavAdapter (List<FavModelClass> favModelClassList, Context
beddingContext) {
this.favModelClassList= favModelClassList;
this.beddingContext = beddingContext;
}
#NonNull
#Override
public FavAdapter.MyViewHolder onCreateViewHolder(#NonNull ViewGroup
parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.amenitylayout,parent,false);
FavAdapter .MyViewHolder holder = new FavAdapter .MyViewHolder(view);
return holder;
}
#Override
public void onBindViewHolder(#NonNull FavAdapter.MyViewHolder holder, int i) {
final FavModelClassdata = favModelClassList.get(i);
holder.ac_bedding_type.setText(data.getFav()+" "+"MAX:"+data.getUser_id());
holder.delete_entry.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
removeAt(holder.getAdapterPosition());
}
});
}
public void removeAt(int position) {
favModelClassList.remove(position);
notifyItemRemoved(position);
notifyItemRangeChanged(position, favModelClassList.size());
}
#Override
public int getItemCount() {
return favModelClassList.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
private TextView ac_bedding_type;
private ImageButton delete_entry;
public MyViewHolder(#NonNull View v) {
super(v);
ac_bedding_type = v.findViewById(R.id.ac_amenity_name);
delete_entry = v.findViewById(R.id.delete_amenity_entry);
}
}
}
Main activity
fav_recycler = findViewById(R.id.fave_recycler);
GridLayoutManager layoutManager1 = new GridLayoutManager(getApplicationContext(), 2,GridLayoutManager.VERTICAL, false);
fav_recycler.setHasFixedSize(true);
fav_recycler.setLayoutManager(layoutManager1);
favModelClassList= new ArrayList<>();
addfavamenity.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
favModelClassList.add(new FavModelClass(
amenityET.getText().toString(),
user_idET.getText().toString()
));
amenityET.setText("");
user_idET.setText("");
FavAdapter adapter = new FavAdapter (favModelClassList, getApplicationContext());
adapter.notifyDataSetChanged();
fav_recycler.setAdapter(adapter);
for (int i = 0; i < favModelClassList.size(); i++) {
final FavModelClassList data = favModelClassList.get(i);
final String fav= data.getFav();
final String user_id = data.getUser_id();
Log.d(TAG, "onClick: "+ fav);
}
}
});
ArrayList d = new ArrayList();
for (int i = 0; i < favModelClassList.size(); i++) {
final FavModelClassList data = favModelClassList.get(i);
d.add(data.getFav());
}
Log.d(TAG, "onClick: " + d);
This Is Main Fragment
Fragment:
private void getStock() {
dialog.show();
Retrofit retrofit = RetrofitClient.getRetrofitInstance();
apiInterface api = retrofit.create(apiInterface.class);
Call<List<Blocks>>call = api.getVaccineBlocks();
call.enqueue(new Callback<List<Blocks>>() {
#Override
public void onResponse(Call<List<Blocks>>call, Response<List<Blocks>> response) {
if (response.code() == 200) {
block = response.body();
spinnerada();
dialog.cancel();
}else{
dialog.cancel();
}
}
#Override
public void onFailure(Call<List<Blocks>> call, Throwable t) {
dialog.cancel();
}
});
}
private void spinnerada() {
String[] s = new String[block.size()];
for (int i = 0; i < block.size(); i++) {
s[i] = block.get(i).getBlockName();
final ArrayAdapter a = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_item, s);
a.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//Setting the ArrayAdapter data on the Spinner
spinner.setAdapter(a);
}
}
This Is Blocks Model
model:
package com.smmtn.book.models;
import java.io.Serializable;
public class Blocks implements Serializable {
public String id;
public String blockName;
public String blockSlug;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getBlockName() {
return blockName;
}
public void setBlockName(String blockName) {
this.blockName = blockName;
}
public String getBlockSlug() {
return blockSlug;
}
public void setBlockSlug(String blockSlug) {
this.blockSlug = blockSlug;
}
}
here i need onitemclick with blockslug please any one can help, am new to android so i need some example.when on click i want take blockslug and load another method with that blockslug,like will get data from u "http://example.com/block/"+blockslug
i want to get blockslug from selected block
i hope guys i will get help
and sorry for my bad English,
First of all, you need to implement setOnItemSelectedListener. Refer to this https://stackoverflow.com/a/20151596/9346054
Once you selected the item, you can call them by making a new method. Example like below
public void onItemSelected(AdapterView<?> parent, View view, int pos,long id) {
Toast.makeText(parent.getContext(),
"OnItemSelectedListener : " + parent.getItemAtPosition(pos).toString(),
Toast.LENGTH_SHORT).show();
final String itemSelected = parent.getItemAtPosition(pos).toString();
showBlockSlug(itemSelected);
}
And then, at the method showBlockSlug() , you can call Retrofit.
private void showBlockSlug(final String blockslug){
final String url = "http://example.com/block/"+ blockslug;
//Do your stuff...
}
I am trying to change one of my textview(Status) when clicked but it just removes the current text and displays my original text's text.
The textview currently display either "Not Taken" or "Pending" depending on what data is retrieved from my db.
My pop up dialog fragment code that shows the card items in a recyclerview.
public class FragmentLocationPopup extends DialogFragment {
View mView;
TextView tvSelectedBranch;
RecyclerView mScheduleList;
ScheduleAdapter mAdapter;
RecyclerView.LayoutManager mLayoutManager;
String TAG = "DialogFragment";
ArrayList<Schedule> scheduleList;
VariablesHolder variablesHolder;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.fragment_location_popup, container, false);
createScheduleList();
buildRecyclerView();
return mView;
}
public void createScheduleList(){
scheduleList = new ArrayList<>();
tvSelectedBranch = mView.findViewById(R.id.tvSelectedBranch);
variablesHolder = (VariablesHolder) getActivity().getApplicationContext();
String selectedBranch = variablesHolder.getSelectedBranch();
tvSelectedBranch.setText(selectedBranch);
Log.d(TAG, "Selected branch = "+selectedBranch);
Call<List<Schedule>> call = RetrofitClient.getInstance().getApiDate().getSchedule();
call.enqueue(new Callback<List<Schedule>>() {
#Override
public void onResponse(Call<List<Schedule>> call, Response<List<Schedule>> response) {
List<Schedule> schedules = response.body();
for (Schedule schedule : schedules) {
if(schedule.getBranchID().equals(variablesHolder.getBranchID())) {
scheduleList.add(new Schedule(schedule.getWorkScheduleFromDateTime(), schedule.getWorkScheduleToDateTime(),schedule.getWorkScheduleStatus()));
Log.d(TAG, "onResponse: " + schedule.getWorkScheduleFromDateTime() + " and " + schedule.getWorkScheduleToDateTime() + " and "+schedule.getWorkScheduleStatus());
}
}
}
#Override
public void onFailure(Call<List<Schedule>> call, Throwable t) {
}
});
String asd = ""+variablesHolder.getBranchIdList();
Log.d(TAG, "onCreateView: "+asd);
}
public void buildRecyclerView(){
mScheduleList = mView.findViewById(R.id.rvScheduleList);
mScheduleList.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(mView.getContext());
mAdapter = new ScheduleAdapter(scheduleList);
mScheduleList.setLayoutManager(mLayoutManager);
mScheduleList.setAdapter(mAdapter);
mAdapter.setOnItemClickListener(new ScheduleAdapter.OnItemClickListener() {
#Override
public void onItemClick(int position) {
changeItem(position, "Clicked");
}
});
}
public void changeItem(int position, String text){
scheduleList.get(position).changeText1(text);
mAdapter.notifyItemChanged(position);
Log.d(TAG, "changeItem: "+position+" / "+text);
}
}
My schedule class (I only use 3 variables in it at the moment) workfromtime, worktotime, and workstatus
public class Schedule {
private String workScheduleID;
private Date workScheduleFromDateTime;
private Date workScheduleToDateTime;
private String workScheduleStatus;
private String workDescriptionID;
private String branchID;
private String staffID;
private String managerID;
private String workScheduleBidDateTime;
public Schedule(Date workScheduleFromDateTime, Date workScheduleToDateTime,String workScheduleStatus) {
this.workScheduleFromDateTime = workScheduleFromDateTime;
this.workScheduleToDateTime = workScheduleToDateTime;
this.workScheduleStatus = workScheduleStatus;
}
public void changeText1(String workScheduleStatus){
this.workScheduleStatus = workScheduleStatus;
}
public String getWorkScheduleID(){return workScheduleID;}
public Date getWorkScheduleFromDateTime(){return workScheduleFromDateTime;}
public Date getWorkScheduleToDateTime(){return workScheduleToDateTime;}
public String getWorkScheduleStatus(){return workScheduleStatus;}
public String getWorkDescriptionID(){return workDescriptionID;}
public String getBranchID(){return branchID;}
public String getStaffID(){return staffID;}
public String getManagerID(){return managerID;}
public String getWorkScheduleBidDateTime(){return workScheduleBidDateTime;}
}
Adapter class
public class ScheduleAdapter extends RecyclerView.Adapter<ScheduleAdapter.ScheduleViewHolder> {
private static final String TAG = "ScheduleAdapter";
private ArrayList<Schedule> mScheduleList;
private OnItemClickListener mListener;
public interface OnItemClickListener{
void onItemClick(int position);
}
public void setOnItemClickListener(OnItemClickListener listener){
mListener = listener;
}
public static class ScheduleViewHolder extends RecyclerView.ViewHolder{
public TextView FromTime,ToTime,ScheduleStatus,Tester;
public ScheduleViewHolder(#NonNull final View itemView, final OnItemClickListener listener) {
super(itemView);
FromTime = itemView.findViewById(R.id.tvFromTime);
ToTime = itemView.findViewById(R.id.tvToTime);
ScheduleStatus = itemView.findViewById(R.id.tvStatus);
Tester = itemView.findViewById(R.id.tvTest);
itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(listener != null){
int position = getAdapterPosition();
if(position != RecyclerView.NO_POSITION){
listener.onItemClick(position);
}
}
}
});
}
}
public ScheduleAdapter(ArrayList<Schedule> scheduleList ){
mScheduleList = scheduleList;
}
#NonNull
#Override
public ScheduleViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View mView = LayoutInflater.from(parent.getContext()).inflate(R.layout.schedule_item,parent,false);
ScheduleViewHolder svh = new ScheduleViewHolder(mView, mListener);
return svh;
}
#Override
public void onBindViewHolder(#NonNull ScheduleViewHolder holder, int position) {
Schedule currentSchedule = mScheduleList.get(position);
Log.d(TAG, "onBindViewHolder: "+currentSchedule.getWorkScheduleFromDateTime() + " and "+currentSchedule.getWorkScheduleToDateTime());
String FromTimeRegion = currentSchedule.getWorkScheduleFromDateTime().toString().replace("GMT 2020","");
String ToTimeRegion = currentSchedule.getWorkScheduleToDateTime().toString().replace("GMT 2020","");
String status = currentSchedule.getWorkScheduleStatus();
Log.d(TAG, "onBindViewHolder: "+status);
if(status.toLowerCase().equals("pending")) {
holder.ScheduleStatus.setText("Pending");
holder.ScheduleStatus.setTextColor(Color.parseColor("#FFFF00"));
}
if(status.toLowerCase().equals("not taken")) {
holder.ScheduleStatus.setText("Not Taken");
holder.ScheduleStatus.setTextColor(Color.parseColor("#7FFF00"));
}
holder.FromTime.setText("From: "+FromTimeRegion);
holder.ToTime.setText("To: "+ToTimeRegion);
}
#Override
public int getItemCount() {
return mScheduleList.size();
}
}
Please advice.
I found out that it is caused by this part of my code.
if(status.toLowerCase().equals("pending")) {
holder.ScheduleStatus.setText("Pending");
holder.ScheduleStatus.setTextColor(Color.parseColor("#FFFF00"));
}
if(status.toLowerCase().equals("not taken")) {
holder.ScheduleStatus.setText("Not Taken");
holder.ScheduleStatus.setTextColor(Color.parseColor("#7FFF00"));
}
holder.FromTime.setText("From: "+FromTimeRegion);
holder.ToTime.setText("To: "+ToTimeRegion);
Just had to edit which comes first.
long story short, I have one settlementItemeBase class as my father and two children. I want to make the father class parcelable so as extension happens, my two child classes be parcelable as well. I don't exactly know what I'm doing right or wrong. I searched little bit but nothing helped me.
here are my classes:
SettlementItemBase:
public class SettlementItemBase implements Parcelable{
public SettlementItemBase(){}
protected SettlementItemBase(Parcel in) {
}
public static final Creator<SettlementItemBase> CREATOR = new Creator<SettlementItemBase>() {
#Override
public SettlementItemBase createFromParcel(Parcel in) {
return new SettlementItemBase(in);
}
#Override
public SettlementItemBase[] newArray(int size) {
return new SettlementItemBase[size];
}
};
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
}
}
first child class:
public class FirstClass extends SettlementItemBase {
private int id;
private int cardId;
private String cardNumber;
private String expDate;
private String currency;
private String url;
public FirstClass(){
id = 0;
cardId = 0;
cardNumber = "";
expDate = "";
currency = "";
url = "";
}
protected FirstClass(Parcel in) {
super(in);
id = in.readInt();
cardId = in.readInt();
cardNumber = in.readString();
expDate = in.readString();
currency = in.readString();
url = in.readString();
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
dest.writeInt(cardId);
dest.writeString(cardNumber);
dest.writeString(expDate);
dest.writeString(currency);
dest.writeString(url);
}
public int getId() {
return id;
}
public int getCardId() {
return cardId;
}
public String getCardNumber() {
return cardNumber;
}
public String getExpDate() {
return expDate;
}
public String getCurrency() {
return currency;
}
public String getUrl() {
return url;
}
}
second child class:
public class SecondClass extends SettlementItemBase{
private int id;
private String currency;
private String accountNumber;
private String ibanNumber;
public SecondClass(int id, String currency,
String accountNumber, String ibanNumber){
this.id = id;
this.currency = currency;
this.accountNumber = accountNumber;
this.ibanNumber = ibanNumber;
}
protected SecondClass(Parcel in){
super(in);
id = in.readInt();
currency = in.readString();
accountNumber = in.readString();
ibanNumber = in.readString();
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
dest.writeString(currency);
dest.writeString(accountNumber);
dest.writeString(ibanNumber);
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCurrency() {
return currency;
}
public String getAccountNumber() {
return accountNumber;
}
public String getIbanNumber() {
return ibanNumber;
}
}
I'm passing and getting an ArrayList of both child class' items with intent putParcelableArrayListExtra and getParcelableArrayListExtra methods and get the following error:
Parcel android.os.Parcel#2d0fde33: Unmarshalling unknown type code 3276849 at offset 172
any help would be appreciated 3>
well I'm posting this for those who may run into the same problem as me.
the problem was solved after adding the Creator statement to the child classes.
for one of the child classes it would be like:
public static final Creator<FirstClass> CREATOR = new Creator<FirstClass>() {
#Override
public FirstClass createFromParcel(Parcel in) {
return new FirstClass(in);
}
#Override
public FirstClass[] newArray(int size) {
return new FirstClass[size];
}
};
hope this helps. 3>
I've use Filterable inside my RecyclerView. What I wanted to do is, to filter the recyclerview from edittext. Below is my actual code.
public class NavDrawerAdapter_v2 extends RecyclerView.Adapter<NavDrawerAdapter_v2.ViewHolder> implements Filterable{
private static final int TYPE_ITEM = 0;
private ArrayList<String> menu_list;
private ArrayList<String> filtered_menu_list;
Context mContext;
public static class ViewHolder extends RecyclerView.ViewHolder {
int Holderid;
TextView shopName, shopLevel;
public ViewHolder(View itemView,int ViewType) {
super(itemView);
shopName = (TextView) itemView.findViewById(R.id.rowText);
shopLevel = (TextView) itemView.findViewById(R.id.rowLevel);
if(ViewType == TYPE_ITEM) {
Holderid = 0;
}
}
}
public NavDrawerAdapter_v2(Context mContext, ArrayList<String> menu_list){
this.menu_list = menu_list;
this.filtered_menu_list = menu_list;
this.mContext = mContext;
}
#Override
public NavDrawerAdapter_v2.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == TYPE_ITEM) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.drawer_item_row,parent,false); //Inflating the layout
return new ViewHolder(v,viewType);
}
return null;
}
#Override
public void onBindViewHolder(NavDrawerAdapter_v2.ViewHolder holder, int position) {
if (holder.Holderid == 0) {
String getShopName = menu_list.get(position).split("-")[0];
String getShopLevel = menu_list.get(position).split("-")[1];
holder.shopName.setText(getShopName);
holder.shopLevel.setText(getShopLevel);
}
}
#Override
public int getItemCount() {
return menu_list == null ? 0 : menu_list.size();
}
#Override
public long getItemId(int position) {
return super.getItemId(position);
}
#Override
public int getItemViewType(int position) {
return TYPE_ITEM;
}
public boolean okay(){
return true;
}
#Override
public Filter getFilter() {
return new UserFilter(this, menu_list);
}
private static class UserFilter extends Filter {
private final NavDrawerAdapter_v2 adapter;
private final ArrayList<String> originalList;
private final ArrayList<String> filteredList;
private UserFilter(NavDrawerAdapter_v2 adapter, ArrayList<String>originalList) {
super();
this.adapter = adapter;
this.originalList = new ArrayList<>(originalList);
this.filteredList = new ArrayList<>();
}
#Override
protected FilterResults performFiltering(CharSequence constraint) {
filteredList.clear();
final FilterResults results = new FilterResults();
if (constraint.length() == 0) {
filteredList.addAll(originalList);
} else {
final String filterPattern = constraint.toString().toLowerCase().trim();
for (String getValue : originalList) {
if (getValue.contains(filterPattern)) {
filteredList.add(getValue);
}
}
}
results.values = filteredList;
results.count = filteredList.size();
return results;
}
#Override
protected void publishResults(CharSequence constraint, FilterResults results) {
adapter.filtered_menu_list.clear();
adapter.filtered_menu_list.addAll((ArrayList<String>) results.values);
adapter.notifyDataSetChanged();
}
}
}
But, in my fragment. I can't call adapter.getFilter(). What is wrong here?
If you want EditText for searchView purposes, you need to add change listener for EditText, as explained in the link : android on Text Change Listener
When the text changed, you should call
adapter.getFilter().filter(newText);
Alternatively, you should try to implement searchview in action bar with recyclerView. Todo this, implement getFilter() method inside your RecyclerView adapter. You can use the getFilter() method implemented in the link https://stackoverflow.com/a/10532898/1308990 .
menu.xml:
<item android:id="#+id/menuSearch"
android:title="search"
android:icon = "#android:drawable/ic_menu_search"
app:actionViewClass = "android.support.v7.widget.SearchView"
app:showAsAction = "always|collapseActionView"></item>
Inside onCreateOptionsMenu() method, write following codes :
MenuItem item = menu.findItem(R.id.menuSearch);
//SearchView searchView = (SearchView) item.getActionView();
SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
//Called when the query text is changed by the user.
#Override
public boolean onQueryTextChange(String newText) {
Log.d("soda in MainActivity","onQueryTextChange method is called.");
mutfagimFragment.adapter.getFilter().filter(newText);
return false;
}
});
When the user changes the text, check whether the onQueryTextChange() method is called by monitoring the logs. If it is not called, try to put the above codes inside onPrepareOptionsMenu() method rather than onCreateOptionsMenu() method.
Following your example, I'm pretty sure you were assigning the object to a RecyclerView.Adapter variable instead of to a NavDrawerAdapter_v2 variable inside the Activity.
RecyclerView.Adapter adapter = new NavDrawerAdapter_v2(menuList);
instead of
NavDrawerAdapter_v2 adapter = new NavDrawerAdapter_v2(menuList);
NavDrawerAdapter_v2 extends from RecyclerView.Adapter but at the same time implements Filterable.
If you assign the object to a RecyclerView.Adapter variable you will still be able to call getItemCount(), onBindViewHolder() and onCreateViewHolder() (since they are abstract methods from RecyclerView.Adapter)
The bad part is that you won't be able to call getFilter() because it belongs to the Filterable interface.