Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- XML code :-
- <Button
- android:id="@+id/button"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="250dp"
- android:text="+" />
- <TextView
- android:id="@+id/textView"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="50dp"
- android:paddingLeft="200dp"
- android:textSize="25sp"
- android:text="0" />
- Java code :-
- 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 {
- Button btn;
- TextView txt;
- protected int a = 1;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- btn = (Button) findViewById(R.id.button);
- txt = (TextView) findViewById(R.id.textView);
- }
- public void display(final int n) {
- btn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- txt.setText(n);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement