作者henry720303 ( )
看板AndroidDev
标题[问题] custom view
时间Wed Jun 1 14:15:34 2011
开发层: (应用/框架/库/核心)
问题:
会当掉
当在xml档加入class以後就当
我的目地是要让button跟我的画布在同一个画面上
输入:
预期输出:
错误输出:
错误讯息:
程式码: (请多利用置底文网站)
-----------------clock.java----------------
package henry.clock
import android.app.Activity;
import android.os.Bundle;
public class clock extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
-----------------------main.xml----------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="
http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<view class="henry.clock.DrawClock"
android:id="@+id/DrawClock"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</view>
<Button android:text="draw" android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
<Button android:text="clear" android:id="@+id/Button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
<Button android:text="Exit" android:id="@+id/Button03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
</LinearLayout>
---------------DrawClock.java------------------------------------------------
package henry.clock;
public class DrawClock extends View
{
public DrawClock(Context context)
{
super(context);
}
public void onDraw(Canvas canvas)
{
paint= new Paint();
canvas.drawCircle(20, 20, 20, paint);
}
}
参考: (书籍/网页/...)
补充说明:
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 111.81.11.187
※ henry720303:转录至看板 java 06/01 14:32