4

私はこのGUIを持っています:

LinearLayout

-TableLayout heading
-ViewFlipper flipper
    - TableLayout1
    - TableLayout2
    - TableLayout3
       ... (dynamicly added)

vf.onLayout(..)でt1の幅を変更しましたが、再描画できません。助けてください:/コードは次のとおりです。

 @Override
 protected void onLayout(boolean changed, int left, int top, int right,
 int bottom) {
 super.onLayout(changed, left, top, right, bottom);

 Log.i(TAG, "flipper onLayout");

 int idx = this.getDisplayedChild();
 Log.i(TAG, "flipper displayed child is: " + idx);
 this.heading.cols_widths = some_cols_widths;
 this.heading.resize_cols();
 LinearLayout lay = (LinearLayout) this.heading.getParent();
 lay.requestLayout();    
 }

これは私を怒らせます:/

4

2 に答える 2

2

コメントによると、ビューを変更するときに、viewFlipper の「ヘッダー」を変更したいと考えています。親を呼び出して requestLayout を呼び出しているので、スーパー コールを最後に移動するだけで、requestlayout を呼び出す必要はありません。

@Override
protected void onLayout(boolean changed, int left, int top, int right,
int bottom) {
  Log.i(TAG, "flipper onLayout");

  int idx = this.getDisplayedChild();
  Log.i(TAG, "flipper displayed child is: " + idx);
  this.heading.cols_widths = some_cols_widths;
  this.heading.resize_cols();

  super.onLayout(changed, left, top, right, bottom);
}

または、resize_cols() で requestLayout 自体を呼び出すこともできます。

于 2012-06-15T18:27:30.757 に答える
1

したがって、答えはnininhoが上に書いたようなものです:

「postDelayed を使用して requestLayout を呼び出します。」

于 2012-07-01T08:40:56.070 に答える