0
我用這個從Android開發人員,但不明白爲什麼它強制關閉:掙扎創建一個簡單的形狀
包com.example.shapedrawable.CustomDrawableView;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.view.View;
public class CustomDrawableViewActivity extends View {
private ShapeDrawable mDrawable;
public CustomDrawableViewActivity(Context context) {
super(context);
int x = 10;
int y = 10;
int width = 300;
int height = 50;
mDrawable = new ShapeDrawable(new OvalShape());
mDrawable.getPaint().setColor(Color.BLUE);
mDrawable.setBounds(x, y, x + width, y + height);
}
protected void onDraw(Canvas canvas) {
mDrawable.draw(canvas);
}
}
你需要點擊DDMS按鈕並查看LogCat。通過點擊小E按鈕來過濾消息,然後運行你的應用程序。它應該告訴你錯誤是什麼。 – Lumis 2012-02-06 23:24:50
謝謝我現在看到它 – user1169775 2012-02-08 12:53:14