+ 3
How to fix this error in fragment.... help :(
here's the code adapter = new ScanItemAdapter(ScanDatabase.get instance(this).getScans(), this); list.setAdapter(adapter); barcodeView.decode continuous(this); I got error on "this" inside getInsance() parameter... what should I do to fix this....?
9 Answers
+ 9
Sorry Bie I couldn't figure out the issue with the information provided. Perhaps you can give it a try on StackOverflow and all the best to you!
+ 8
Can we know the exact error message you got? If you're unable to compile the code, then most likely it's because the getInstance method was expecting another data type besides the current context from "this".
+ 4
I think you have a custom class named Fragment_scan it is asking for its object.
+ 3
It might be asking for context. try getContext(), getActivityContext() or getActivity(). It might work.
If it doesn't solve the error then provide the error message.
+ 2
getContext(), getActivity(), getActivityContext() doesn't work.... but it work in statement below;
private void addScanItem(String barcode) {
adapter.addItem(ScansDatabase.getInstance(getContext()).addItem(barcode));
}
here's the error message
getInstance (Android.content.Context) in ScansDatabase cannot be applied to
(com.name.scammer.Fragment_scan)
+ 2
custom class means a class that you have created.
+ 2
but I still don't understand, why only this line of code not working...(getContext(), getActivity(),...can't apply).
adapter = new ScanItemAdapter(ScanDatabase.get instance(this).getScans(), this);
list.setAdapter(adapter);
barcodeView.decode continuous(this);
but no error on this line...
private void addScanItem(String barcode) {
adapter.addItem(ScansDatabase.getInstance(getContext()).addItem(barcode));
+ 2
Is ok Zephyr...thanks for trying to help.... I will try another way to do it....
0
can i know what does "custom class" mean? :(