I am having lots of troubles with this. It is working properly on my Nexus 7 tablet, but not on my Samsung S3.
I am adding views to a LinearLayout called ItemsBar, but nothing shows up inside it until I press the screen off button and then screen on, or if I leave the app by switching to another app and back to it. Showing the keyboard also shows the views.
//Load Images into ItemBar
for (int currentItemImage : ItemIDs){
ImageView i = new ImageView(this);
i.setImageResource(currentItemImage);
i.setTag(currentItemImage);
i.setClickable(true);i.setPadding(4, 0, 4, 0);
i.setOnClickListener(ItemOnClick);
i.setLayoutParams(ItemLP);
ItemsBar.addView(i);
}
This is not done at OnCreate. It is done on button click. The OnStart and OnResume are unused.
By inspecting, the layout does have 20 children.
Note: to prove that there is nothing wrong with this code, resources, and Params, they actually do show up after screen turn off or switching app. And this works perfectly on the Nexus 7.
I tried using invalidate() to children and to the layout, to no avail.
What can I do?
The error was in OnLayoutChangeListener(). It seems that Nexus 7 with Android 4.3 dealt differently (maybe requested it differently) than my Samsung S3 with Android 4.1.2. I had to remove it completely.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다