









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Code: XML:
android:inputType="textPostalAddress" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.865" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/editTextPhone" app:layout_constraintVertical_bias="0.225" /> </androidx.constraintlayout.widget.ConstraintLayout>
CODE JAVA EditText a1,t1; Button b1=findViewById(R.id.button2); a1=findViewById(R.id.id_1); b1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { TextView t=findViewById(R.id.textView6); String s =a1.getText().toString(); t.setText("hello " +s);
} });
app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.0" />
Button plus=findViewById(R.id.button); Button minus=findViewById(R.id.button2); Button multiply=findViewById(R.id.button3); Button divide=findViewById(R.id.button4); plus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int num1 = Integer.parseInt(e1.getText().toString()); int num2 = Integer.parseInt(e2.getText().toString()); TextView tv = findViewById(R.id.textView); tv.setText(Integer.toString(num1 + num2)); } }); minus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int num1 = Integer.parseInt(e1.getText().toString()); int num2 = Integer.parseInt(e2.getText().toString()); TextView tv = findViewById(R.id.textView); tv.setText(Integer.toString(num1 - num2)); } }); multiply.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int num1 = Integer.parseInt(e1.getText().toString()); int num2 = Integer.parseInt(e2.getText().toString()); TextView tv = findViewById(R.id.textView); tv.setText(Integer.toString(num1 * num2)); } }); divide.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int num1 = Integer.parseInt(e1.getText().toString()); int num2 = Integer.parseInt(e2.getText().toString()); TextView tv = findViewById(R.id.textView); tv.setText(Integer.toString(num1 / num2)); } }); } } XML: