update
This commit is contained in:
@ -1,11 +1,44 @@
|
||||
package com.rookiedev.hexapod
|
||||
|
||||
import android.net.InetAddresses.isNumericAddress
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.widget.Button
|
||||
import android.widget.Toast
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import android.text.Editable
|
||||
|
||||
import android.text.TextWatcher
|
||||
|
||||
|
||||
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
val ipInput = findViewById<TextInputEditText>(R.id.ip_input)
|
||||
val portInput = findViewById<TextInputEditText>(R.id.port_input)
|
||||
val buttonConnect = findViewById<Button>(R.id.button_connect)
|
||||
|
||||
buttonConnect.setOnClickListener {
|
||||
// your code to perform when the user clicks on the button
|
||||
|
||||
Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
|
||||
ipInput.addTextChangedListener(object : TextWatcher {
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
||||
override fun afterTextChanged(s: Editable) {
|
||||
if (isNumericAddress(s.toString())){
|
||||
Toast.makeText(this@MainActivity, "Correct", Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Toast.makeText(this@MainActivity, "Wrong", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -21,16 +21,17 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/ip_input"
|
||||
android:id="@+id/ip_input_layout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/port_input"
|
||||
app:layout_constraintBottom_toTopOf="@id/port_input_layout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/hexapod_logo" >
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/ip_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number|numberDecimal"
|
||||
@ -39,16 +40,17 @@
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/port_input"
|
||||
android:id="@+id/port_input_layout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/button_first"
|
||||
app:layout_constraintBottom_toTopOf="@id/button_connect"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/ip_input">
|
||||
app:layout_constraintTop_toBottomOf="@id/ip_input_layout">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/port_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
@ -57,7 +59,7 @@
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_first"
|
||||
android:id="@+id/button_connect"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
|
Reference in New Issue
Block a user