Chie Paliza於 2016年12月2日星期五 UTC+8下午1時16分10秒寫道:
>
>
> I got an error in adapter.getRef(position).removeValue();
>
>
> FATAL EXCEPTION: main
>
> java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
> at
> java.util.ArrayList.get(ArrayList.java:306)
> at
> com.firebase.ui.database.FirebaseArray.getItem(FirebaseArray.java:52)
> at
> com.firebase.ui.database.FirebaseRecyclerAdapter.getRef(FirebaseRecyclerAdapter.java:150)
> at
> com.example.maecea.ipon4.Expenses$3$1$2.onClick(Expenses.java:281)
> at
> android.support.v7.app.AlertController$ButtonHandler.handleMessage(AlertController.java:157)
> at
> android.os.Handler.dispatchMessage(Handler.java:99)
> at
> android.os.Looper.loop(Looper.java:137)
> at
> android.app.ActivityThread.main(ActivityThread.java:4745)
> at
> java.lang.reflect.Method.invokeNative(Native Method)
> at
> java.lang.reflect.Method.invoke(Method.java:511)
> at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
> at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
> at
> dalvik.system.NativeStart.main(Native Method)
>
>
> viewHolder.mView.setOnClickListener(new View.OnClickListener() {
> @Override
> public void onClick(View v) {
>
> AlertDialog.Builder builder = new AlertDialog.Builder(Expenses.this);
> builder.setMessage("Gusto mo ba talaga burahin ito, katulad ng
> pagkalimot niya sayo?").setCancelable(false)
> .setPositiveButton("Yes", new
> DialogInterface.OnClickListener() {
> @Override
> public void onClick(DialogInterface dialog, int which) {
>
> adapter.getRef(position).removeValue();
> adapter.notifyDataSetChanged();
> //Intent NotesIntent = new Intent(getApplication(),
> Notes.class);
> //startActivity(NotesIntent);
> }
> })
> .setNegativeButton("No", new
> DialogInterface.OnClickListener() {
> @Override
> public void onClick(DialogInterface dialog, int which) {
> dialog.cancel();
> }
> });
> AlertDialog dialog =builder.create();
> dialog.setTitle("Expenses");
> dialog.show();
>
> }
> });
>
>
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/e1e59722-819e-4756-84df-03effc9465b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.