2
重绘帆布我有一个扩展视图类和具有的onDraw方法来实现 在我的XML文件我有我的观点一的FrameLayout和RelativeLayout的一个按钮如何在一个视图从活动
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<canvas.pruebas.MyView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:id="@+id/btn"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="hello"
android:textSize="15sp"
/>
</RelativeLayout>
</FrameLayout>
在我的Activity类中,我想实现当我单击按钮时重画MyView类中的画布
public class CanvasActivity extends Activity {
Button btn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn=(Button)findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//redraw canvas
}
});
}
}
我该怎么做?
感谢,这是我需要 – jos11 2013-05-11 22:16:53
@ jos11。如果这对你有用,你能接受它作为答案吗? – petey 2017-03-16 18:44:31
对不起,你的答案从来没有被接受,但从我+1做我需要的东西! – kalenpw 2017-06-22 22:34:18