Answer the question
In order to leave comments, you need to log in
How to properly implement an interface with dynamic addition of fragments?
Good afternoon!
There was a difficulty in implementing layout using fragments.
There is a template according to which it is necessary to lay out the page.
How I approach this task:
1) I create MainActivity
2) I add textView (for header), linearLayout (for fragments) and textView (for footer) to MainActivity markup.
3) In MainActivity I loop through the data (image id) and create fragments
for (int photoId : photoNumbers) {
fragmentManager = getFragmentManager();
PhotoFragment fragment = PhotoFragment.newInstance();
Bundle bundle = new Bundle();
bundle.putLong("id", photoId);
sectorBoulderFragment.setArguments(bundle);
fragmentManager.beginTransaction()
.add(R.id.container, fragment, "fragmentId" + photoId)
.commit();
}
Bitmap bitmap = BitmapFactory.decodeByteArray(photos.get(0).getPhotoData(), 0, photos.get(0).getPhotoData().length);
fragmentPhoto.setImageBitmap(bitmap);
ImageView imageView = new ImageView(getActivity().getApplicationContext());
imageView.setImageBitmap(bitmap);
test_linear_layout.addView(imageView);
Answer the question
In order to leave comments, you need to log in
maybe I misunderstood what you need, but in my opinion ListView or RecyclerView will suit you
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question