android:onClick事件

android:onClick事件用户捕获用户的点击,在Activity里面实现点击的处理逻辑。

    <Button

        android:text="@string/hello_world"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:onClick="sendMessage"/>
    public void sendMessage(View view)

    {

        // Create the text view

        TextView textView = new TextView(this);

        textView.setTextSize(40);

        textView.setText("ok");



        // Set the text view as the activity layout

        setContentView(textView);



    }

 

你可能感兴趣的:(android)