public class DrawView extends View implements OnTouchListener {
private static final String TAG = "DrawView";
List<Point> points = new ArrayList<Point>();
Paint paint = new Paint();
public DrawView(Context context) {
super(context);.......
* 私はこのクラスは描画行のために長いコードがあり、これは動作していますが、それは黒、青または他の無地の色で作業しています私はそれを私のレイアウト*自分のレイアウトに線を描画するにはどうすればよいですか?
public class matchFun extends Activity {
DrawView drawView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
drawView = new DrawView(this);
// setContentView(R.layout.matchfun);
// setContentView(drawView);
drawView.setBackgroundResource(R.layout.matchfun);
drawView.requestFocus();....
* これは私が第二のクラスで線を描画したい上位1を継承しているクラスがある*
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/back_lightblue"
>
<ImageView
android:id="@+id/widget32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="4dp"
android:layout_y="118dp"
android:src="@drawable/ic_launcher"
android:onClick="buttonClickHandler"
android:clickable="true"/>
<ImageView
android:id="@+id/widget33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="7dp"
android:layout_y="196dp"
android:src="@drawable/ic_launcher"
android:onClick="buttonClickHandler"
android:clickable="true"/>
これは私のXMLです。何か考えてくださいこの問題を解決してください私は最後のカップルからそれに取り組んで何も解決策を見つけることができませんでした
1日前に似たような質問をしました:http://stackoverflow.com/questions/9296712/android-how-to-draw-a-simple-line-and-display-it-in-a-widgetあなたは検索について知っていますか? – Silver