-1

I got a custom array or list.Which is like :

final List<Haber> haberler = new ArrayList<Haber>();

Haber is my custom class. I want to do :

listemiz.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    AlertDialog.Builder diyalogOlusturucu =
                            new AlertDialog.Builder(getActivity(),R.style.DialogTheme);

                    diyalogOlusturucu.setMessage(haberler[position])
                            .setCancelable(false)
                            .setPositiveButton("Tamam", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                }
                            });
                    diyalogOlusturucu.create().show();

                }
            });

but

haberler[position] 

is not working as expected. What can i do about that ? All code of my project : Haberler.java which hold these codes : https://gist.github.com/ShockvaWe/05fb28543032cc018778dedf5d9f4c04 Haber.java which is my custom class : https://gist.github.com/ShockvaWe/ddf0cbd1ad766977ff28e4409ba51b4b

Dima Kozhevin
  • 3,602
  • 9
  • 39
  • 52

1 Answers1

1

Try haberler.get(position). See ArrayList.

Cheticamp
  • 61,413
  • 10
  • 78
  • 131
  • I already tried it.It gives the error message which is "Cannot Resolve Method setMessage(upiynar.cback.Haber)". – Nicky Romero Oct 26 '17 at 19:13
  • @NickyRomero `setMessage()` of `AlertDialog.Builder` does not take an argument of type `Haber`. It does take an id or a `CharSequence` as an argument. See [AlertDialog.Builder](https://developer.android.com/reference/android/app/AlertDialog.Builder.html#setMessage(int)) for more information. – Cheticamp Oct 26 '17 at 20:10
  • I made it done working.Thanks. – Nicky Romero Oct 26 '17 at 20:14