Beyjanov Umidbek Mobil ilovalarni yaratish. 1-modul xml fayl kodi
Download 477.54 Kb.
|
Beyjanov Umidbek.1-modul
- Bu sahifa navigatsiya:
- .java fayli kodi
Beyjanov Umidbek Mobil ilovalarni yaratish.1-modul .xml fayl kodi xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:orientation="vertical"> android:layout_height="wrap_content" android:orientation="vertical"> android:layout_height="wrap_content" android:id="@+id/war" android:inputType="number" android:hint="Nomer 1"/> android:layout_height="wrap_content" android:id="@+id/car" android:inputType="number" android:hint="Nomer 2"/> android:layout_height="wrap_content" android:gravity="center_horizontal" android:id="@+id/home" android:text="Natija" android:layout_marginTop="20dp" android:textSize="40sp" /> android:layout_width="80dp" android:layout_height="wrap_content" android:text="+" android:layout_marginLeft="30dp" android:id="@+id/RASCAL"/> android:id="@+id/jh" android:layout_width="80dp" android:layout_height="wrap_content" android:layout_marginLeft="30dp" android:text="-" /> android:layout_width="80dp" android:layout_height="wrap_content" android:text="*" android:layout_marginLeft="30dp" android:id="@+id/AT"/> android:layout_width="80dp" android:layout_height="wrap_content" android:text="/" android:layout_marginLeft="30dp" android:id="@+id/SP"/> .java fayli kodi package com.example.myapplication; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class MainActivity extends AppCompatActivity { private Button op, btn,l,abc; EditText num1, num2; TextView res; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); op = findViewById(R.id.jh); l=findViewById(R.id.AT); abc=findViewById(R.id.SP); num1 = findViewById(R.id.war); num2 = findViewById(R.id.car); res = findViewById(R.id.home); btn = findViewById(R.id.RASCAL); op.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { double n1, n2, result; n1 = Double.parseDouble(num1.getText().toString()); n2 = Double.parseDouble(num2.getText().toString()); result = n1-n2; if(result == (int) result){ res.setText(String.valueOf((int)result)); }else{ res.setText(String.valueOf(result)); } }
btn.setOnClickListener(new View.OnClickListener() {
l.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { double n1, n2, result; n1 = Double.parseDouble(num1.getText().toString()); n2 = Double.parseDouble(num2.getText().toString()); result = n1 * n2; if(result == (int) result){ res.setText(String.valueOf((int)result)); }else{ res.setText(String.valueOf(result)); } } }); abc.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { double n1, n2, result; n1 = Double.parseDouble(num1.getText().toString()); n2 = Double.parseDouble(num2.getText().toString()); result = n1 / n2; if(result == (int) result){ res.setText(String.valueOf((int)result)); }else{ res.setText(String.valueOf(result)); } } }); } } Download 477.54 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling