Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
GreenGeeks Web Hosting - Faster, Scalable & Eco-Friendly

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


7,804 questions

10,890 answers

573 users

How to add onClick event to Button in Android Java

1 Answer

0 votes
package com.example.avi.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button myButton =(Button) findViewById(R.id.myButton);

        myButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                TextView myText = (TextView) findViewById(R.id.myText);
                myText.setText("android java");
            }
        });
    }
}

 




answered Mar 27, 2017 by avibootz
...