简体   繁体   中英

Wait till the view is fully updated: How to?

I'm inflating a ViewGroup for export into a PDF document. After inflating it from xml file I am filling it with images and texts. Now when I try to draw this ViewGroup in the canvas of a PDF page, the height of the VieGroup is zero. And the canvas is empty.

This is the code:

View pdfRowLayout = ltInflater.inflate(R.layout.pdf_export_row_layout,
                    (ViewGroup) parent, false);

            TextView action = (TextView) pdfRowLayout.findViewById(R.id.pdf_action_field);
            action.setText(host.getDataProvider().getChildItem(curGroupPosition, 1).getText());

            ImageView avatar = (ImageView) pdfRowLayout.findViewById(R.id.pdf_avatar);
            avatar.setImageBitmap(host.getDataProvider().getGroupItem(curGroupPosition).getGroupImage());

I understand that I need to wait till the layout is fully inflated with a specific listener. But do I have to wait somehow for all the data to get in resizing the layout?

您可以简单地使用片段/活动的onResume()侦听器,此方法使片段/活动开始与用户交互,这意味着该片段对于用户是完全可见的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM