Wie neu Leinwand in einer Ansicht von der Tätigkeit

Ich habe eine Klasse, die Sie erweitert und haben die onDraw-Methode implementiert
in meiner xml-Datei habe ich ein FrameLayout mit meinem Blick und ein RelativeLayout mit einem Knopf

<?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>

in meine Activity-Klasse, die ich umsetzen will, wenn ich auf die Schaltfläche Neuzeichnen des canvas-Bereichs in MyView Klasse

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
            }
        });
    }
}

Wie Kann ich das tun?

InformationsquelleAutor jos11 | 2013-05-08

Schreibe einen Kommentar