2011-10-08 8 views
0

私はAndroid用のゲームを作成していますが、組み込みのレイアウトシステムを使用して、画面のサイズと形状に基づいてレイアウトすることもできます動的に方向が変わるため)、View-derivedクラス(RenderableViewと呼ばれる)でラップされたインターフェース(Renderableと呼ばれる)を作成しました。Android用Eclipse開発:レイアウトエディタのカスタムビューダイアログ

私は、Eclipseの最新バージョンを使用しておりますので、を行いレイアウトエディタのツールパレットのカスタム&ライブラリビューのセクションでは、私のクラスを示すが、各ビューの派生クラスのコピーをいくつか示しています。

これはEclipseまたはコードでのバグですか?ここで

は私のレンダリング可能インターフェースです:

package games.DigSite; 

import android.graphics.*; 

public interface Renderable 
{ 
    /** 
    * Sets the new position and size for this Renderable. 
    * @param bounds THe new bounds for this Renderable. 
    */ 
    public void setBounds(RectF bounds); 

    /** 
    * Returns the current position and size of this Renderable. 
    * @return The bounds this Renderable has. 
    */ 
    public RectF getBounds(); 

    /** 
    * Tells the Renderable to draw itself. 
    * @param canvas The Canvas to draw to. 
    */ 
    public void render(Canvas canvas); 
} 

そして、ここでは私のRenderableViewクラスのコードです:

package games.DigSite; 
import games.DigSite.play.*; 
import android.content.*; 
import android.graphics.*; 
import android.util.*; 
import android.view.*; 
import android.view.SurfaceHolder.Callback; 

public class RenderableView extends SurfaceView implements Callback, PlayConstants 
{ 
    private RectF bounds; 
    private Renderable renderable; 

    public RenderableView(Context context) 
    { 
     super(context); 
     getHolder().addCallback(this); 
    } 

    public RenderableView(Context context, AttributeSet attrs) 
    { 
     super(context, attrs); 
     getHolder().addCallback(this); 
    } 

    public RenderableView(Context context, AttributeSet attrs, int defStyle) 
    { 
     super(context, attrs, defStyle); 
     getHolder().addCallback(this); 
    } 

    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) 
    { 
     bounds = new RectF(0, 0, width, height); 
     if (renderable != null) 
      renderable.setBounds(bounds); 
    } 

    public void setRenderable(Renderable render) 
    { 
     renderable = render; 
    } 

    public Renderable getRenderable() 
    { 
     return renderable; 
    } 

    public void surfaceCreated(SurfaceHolder holder) 
    { 
     // Dunno if we need this one just yet 
    } 

    public void surfaceDestroyed(SurfaceHolder holder) 
    { 
     // Dunno if we need this one just yet 
    } 

    public void onDraw(Canvas canvas) 
    { 
     if (renderable != null) 
      renderable.render(canvas); 
     else 
     { 
      Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 
      paint.setColor(BACKGROUND_COLOUR); 
      canvas.drawRect(bounds, paint); 
     } 
    } 
} 

私は、これはこれを依頼する場所であるかどうかわからないんだけど、そうしてくださいこれを必要に応じて検閲する。

答えて

2

これはADTのバグです。 Eclipseコード検索エンジンは同じクラスを2回返します。カスタムビューを蓄積するデータ構造をListを使ってSetを使うことに変更しました。この修正はADT 15に入ります。

+1

変更セットはI4dd9aafe76404efcf8b7bc82a5392f6010ba16f2 –

+0

です。ありがとうございました!今は私を悩ませている... – Raceimaztion

関連する問題