how can I find a fragment (framelayout) without id?
Here is my code:
private void setRect(int _x, int _y, int _w, int _h){
final Rect rect = new Rect(_x,_y,_w,_h);
final PSPDFConfiguration configuration = new PSPDFConfiguration.Builder(BuildConfig.PSPDFKIT_LICENSE_KEY)
.scrollDirection(PageScrollDirection.HORIZONTAL)
.build();
final Uri assetFile = Uri.parse("file:///android_asset/psp.pdf");
final FrameLayout frameLayout = new FrameLayout(thisContext);
runOnUiThread(new Thread(new Runnable() {
@Override
public void run() {
frameLayout.setId(View.generateViewId());
FrameLayout.LayoutParams params;
params = new FrameLayout.LayoutParams(rect.right-rect.left,rect.bottom-rect.top);
params.leftMargin = rect.left;
params.topMargin = rect.top;
params.gravity = 0;
frameLayout.setLayoutParams(params);
viewer_one.setLayoutParams(params);
viewer_one.getSettings().setBuiltInZoomControls(true);
viewer_one.setBackgroundColor(Color.BLUE);
thisActivity.addContentView(viewer_one,params);
PSPDFFragment fragment;
FragmentManager manager = getSupportFragmentManager();
fragment = (PSPDFFragment) manager.findFragmentById(frameLayout.getId());
if(fragment == null){
fragment = PSPDFFragment.newInstance(assetFile,configuration);
getSupportFragmentManager()
.beginTransaction()
.replace(frameLayout.getId(), fragment)
.commit();
}
}
}));
}
I don't use a framelayout in my layout xml.
Update:
I have update my code and get this error -> No view found for id 0x1 (unknown) for fragment PSPDFFragment{373f9470