0
我希望每次都能獲得佈局的高度,但現在我可以在for循環完成時獲得佈局的高度。有沒有人知道如何在for循環中每次獲得高度?getViewTreeObserver for for循環不工作,爲什麼?
for (int i = 0; i < deelnemers.size(); i++) {
inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View informatie = inflater.inflate(R.layout.modeldeelnemer, null);
TextView volgNummer = (TextView) informatie.findViewById(R.id.volgnummer);
volgNummer.setText("Nummer: " + deelnemers.get(i).getVolgnummer() + " /");
lLayout.addView(informatie);
lLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
lLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
int height = lLayout.getMeasuredHeight();
int width = lLayout.getMeasuredWidth();
}
});
}