3

I want to replace a ListView item with a Fragment when certain conditions are met, but the View, inside which I want to add it has no id (i.e. view's getId() returns 0xffffffff)

View view = lv.getChildAt(pos);
FragmentManager fm = ((PagerAdapter)getAdapter()).getItem(getCurrentItem()).getChildFragmentManager();
fm.beginTransaction().add(view.getId(), new AddPlaylistItemFragment()).commit();

view is a LinearLayout if it helps.

Any ideas on how to solve this

E/AndroidRuntime(1731): android.content.res.Resources$NotFoundException: Unable to find resource ID #0xffffffff

error?

mewa
  • 1,442
  • 1
  • 12
  • 20

1 Answers1

0

You have to give them an ID. Or a tag. The view is coming from your listview, you put it in there. Probably using an adapter's getView. There where you create the view, give it an ID or a tag.

This one might be interesting Android: View.setID(int id) programmatically - how to avoid ID conflicts?

Community
  • 1
  • 1
ElDuderino
  • 3,196
  • 2
  • 18
  • 35