Commit 78f084cf authored by Thibault Santonja's avatar Thibault Santonja
Browse files

Add Exchange button

parent 2a8aec35
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -8,6 +8,7 @@ import android.text.TextWatcher;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
......@@ -22,6 +23,7 @@ public class MainActivity extends AppCompatActivity {
private EditText currencyBottom;
private Spinner spinnerCurrencyTop;
private Spinner spinnerCurrencyBottom;
private Button exchange;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -123,4 +125,14 @@ public class MainActivity extends AppCompatActivity {
public void onNothingSelected(AdapterView<?> parent) { }
});
}
public void onClickExchange(View view) {
String top = currencyTop.getText().toString();
currencyTop.setText(currencyBottom.getText().toString());
currencyBottom.setText(top);
int topSpinner = (int) spinnerCurrencyTop.getSelectedItemId();
spinnerCurrencyTop.setSelection((int) spinnerCurrencyBottom.getSelectedItemId());
spinnerCurrencyBottom.setSelection(topSpinner);
}
}
......@@ -50,4 +50,14 @@
app:layout_constraintStart_toEndOf="@+id/currencyBottom"
app:layout_constraintTop_toTopOf="@+id/currencyBottom" />
<Button
android:id="@+id/exchange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exchange"
android:onClick="onClickExchange"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/coucou"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment