Ahmed Yahya Aljilani
unknown
plain_text
3 years ago
5.3 kB
4
Indexable
package com.example.capacitiesconverter
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
button.setOnClickListener({
var x=editTextNumber.text.toString()
var result=0.0
if (x.toDouble()>6000) {
var Al=AlertDialog.Builder(this)
Al.setTitle("Warnning")
Al.setMessage("Enter a reasonable capacity !!")
Al.setPositiveButton("?????"){DialogInterface,which-> Toast.makeText(this,"DONE",Toast.LENGTH_SHORT).show() }
Al.setNeutralButton("????") {DialogInterface, which-> Toast.makeText(this,"OK",Toast.LENGTH_SHORT).show()}
val alertDialog: AlertDialog = Al.create()
alertDialog.show()
}
// textView.text="Enter a reasonable tempreture !!"}
else if {(
{
result = (x.toDouble() * 1024)
textView.text = result.toString()
val t = Toast.makeText(this, "DONE", Toast.LENGTH_SHORT)
t.show()
// t.setGravity(Gravity.START,200,200)
}
}
})
button2.setOnClickListener({
var x=editTextNumber.text.toString()
var result=0.0
textView.text="هل ترغب بإغلاق البرنامج؟ "
}
}
}
**************************************************************************************************************
**************************************************************************************************************
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#CCFFFF"
tools:context=".MainActivity">
<TextView
android:layout_width="239dp"
android:layout_height="32dp"
android:text="أدخل قيمة بالجيجا بايت"
android:textColor="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.425"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.021" />
<TextView
android:id="@+id/textView"
android:layout_width="541dp"
android:layout_height="47dp"
android:background="@color/yalou"
android:text="الحجم الإجمالي بالميجا:"
android:textColor="@color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.937"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="67dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="542dp"
android:layout_height="43dp"
android:background="@color/yalou"
android:text="الحجم الإجمالي بالكيلو بايت:"
android:textColor="@color/black"
tools:layout_editor_absoluteX="2dp"
tools:layout_editor_absoluteY="208dp" />
<TextView
android:id="@+id/textView3"
android:layout_width="542dp"
android:layout_height="58dp"
android:background="@color/yalou"
android:text="الحجم الإجمالي بالميجا:"
android:textColor="@color/black"
tools:layout_editor_absoluteX="2dp"
tools:layout_editor_absoluteY="323dp" />
<TextView
android:id="@+id/textView4"
android:layout_width="544dp"
android:layout_height="61dp"
android:background="@color/yalou"
android:text="الحجم الإجمالي بالبت:"
android:textColor="@color/black"
tools:layout_editor_absoluteX="2dp"
tools:layout_editor_absoluteY="478dp" />
<Button
android:id="@+id/button"
android:layout_width="537dp"
android:layout_height="49dp"
android:backgroundTint="@color/black"
android:text="أضغط هنا للتحويل"
android:textColor="@color/white"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="604dp" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/RED"
android:text="خروج"
android:textColor="@color/white"
tools:layout_editor_absoluteX="215dp"
tools:layout_editor_absoluteY="676dp" />
</androidx.constraintlayout.widget.ConstraintLayout>Editor is loading...