I have an ArrayList
where I store array of items of a specific field of a document, and I am sending it to another activity like this:
Intent intent = new Intent(ProgramToProgram.this, com.example.newapp.ProgramToProgram1.class);
intent.putExtra("fids", arrayList1);
startActivity(intent);
I recieve it in the other activity like this:
arraylist3 = (ArrayList<String>)getIntent().getSerializableExtra("fids");
Now I have another array list in this activty where I am storing another set of items:
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
pid = docIds.get(position);
fgboys1.whereEqualTo("pid", pid)
.get()
.addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
for (QueryDocumentSnapshot documentSnapshot : queryDocumentSnapshots) {
String fid = documentSnapshot.get("fid").toString();
arrayList1.add(fid);
arrayAdapter1.notifyDataSetChanged();
}
Toast.makeText(ProgramToProgram1.this, "FIND OUT REGISTERED OR NOT REGISTERED", Toast.LENGTH_SHORT).show();
}
});
}
});
Now I want to compare the items of arraylist3 and arraylist1 and return the number of items and the similar items. How do I do it?
This is what I have tried, but the app crashes each time:
registered.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int i;
arraylist3 = (ArrayList<String>)getIntent().getSerializableExtra("fids");
for (i = 0; i <arraylist3.size(); i++) {
if (arraylist3.contains(arrayList1.get(i))) {
i++;
}
}
tv_reg.setText(i);
}
});
this is the error shown in log :
2020-02-12 11:50:19.014 16489-16489/com.example.newapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.newapp, PID: 16489
android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.content.res.Resources.getText(Resources.java:338)
at android.widget.TextView.setText(TextView.java:5494)
at com.example.newapp.ProgramToProgram1$4.onClick(ProgramToProgram1.java:215)
at android.view.View.performClick(View.java:6256)
at android.view.View$PerformClick.run(View.java:24701)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)