Answer the question
In order to leave comments, you need to log in
Unable to get methods from interface in fragment. How can this be fixed?
Why, when trying to get methods from the interface, writes Cannot resolve method 'isProduct()'
and Cannot resolve method 'getMenuTitle()'
. ourMenuItems
I write likeArrayList
private final ArrayList<MenuPosition> ourMenuItems = new ArrayList<>();
@Override
public void onItemClick(View object, int n2) {
try {
object = (View) this.ourMenuItems.get(n2);
if (!object.isProduct()) {
if (this.materialFragmentActivityCallback != null) {
object = CatalogFragment.instance(object.getId(), object.getMenuTitle());
this.materialFragmentActivityCallback.beginFragmentManagerTransaction((Fragment)object, true);
return;
}
} else {
Intent intent = new Intent(getActivity(),ProductActivity.class);
intent.putExtra("PRODUCT_ID", object.getId());
this.startActivity(intent);
}
return;
}
catch (Exception exception) {
return;
}
}
Answer the question
In order to leave comments, you need to log in
You yourself cast an object from the list to View . Even if you remove the calls and compile, it will still fall with a ClassCastException. Java has static typing.
What's the savings on variables? The fact that you named the variable object does not mean that you can shove anything into it. Select normal variables of the appropriate types, and you will be happy.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question