Add swap button to route form
This commit is contained in:
parent
44b1a1983a
commit
756545d491
@ -14,6 +14,8 @@ import android.support.v7.app.AlertDialog;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -80,6 +82,16 @@ public abstract class AbstractRouteSelectionFragment extends DialogFragment {
|
|||||||
.findViewById(R.id.destination_spinner);
|
.findViewById(R.id.destination_spinner);
|
||||||
destinationSpinner.setAdapter(destinationSpinnerAdapter);
|
destinationSpinner.setAdapter(destinationSpinnerAdapter);
|
||||||
destinationSpinner.setSelection(lastSelectedDestinationPosition);
|
destinationSpinner.setSelection(lastSelectedDestinationPosition);
|
||||||
|
|
||||||
|
final ImageButton swapButton = (ImageButton) dialog.findViewById(R.id.swap_button);
|
||||||
|
swapButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
int destinationSelection = destinationSpinner.getSelectedItemPosition();
|
||||||
|
destinationSpinner.setSelection(originSpinner.getSelectedItemPosition());
|
||||||
|
originSpinner.setSelection(destinationSelection);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
BIN
app/src/main/res/drawable-hdpi/ic_action_action_swap_vert.png
Executable file
BIN
app/src/main/res/drawable-hdpi/ic_action_action_swap_vert.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 514 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_action_swap_vert.png
Executable file
BIN
app/src/main/res/drawable-mdpi/ic_action_action_swap_vert.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 310 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_action_swap_vert.png
Executable file
BIN
app/src/main/res/drawable-xhdpi/ic_action_action_swap_vert.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 575 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_action_swap_vert.png
Executable file
BIN
app/src/main/res/drawable-xxhdpi/ic_action_action_swap_vert.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 924 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_action_action_swap_vert.png
Executable file
BIN
app/src/main/res/drawable-xxxhdpi/ic_action_action_swap_vert.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -38,16 +38,25 @@
|
|||||||
android:text="@string/origin"
|
android:text="@string/origin"
|
||||||
android:textSize="15sp"></TextView>
|
android:textSize="15sp"></TextView>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/swap_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_action_action_swap_vert"
|
||||||
|
style="?android:attr/borderlessButtonStyle"
|
||||||
|
android:layout_alignLeft="@id/origin_spinner"
|
||||||
|
android:layout_below="@id/origin_spinner"
|
||||||
|
/>
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/destination_spinner"
|
android:id="@+id/destination_spinner"
|
||||||
android:layout_width="200dp"
|
android:layout_width="200dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_below="@+id/origin_spinner"
|
android:layout_below="@+id/swap_button"
|
||||||
android:drawSelectorOnTop="true"
|
android:drawSelectorOnTop="true"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
android:paddingTop="15dip"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -56,11 +65,10 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBottom="@+id/destination_spinner"
|
android:layout_alignBottom="@+id/destination_spinner"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_below="@+id/origin_spinner"
|
android:layout_below="@+id/swap_button"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
android:paddingTop="15dip"
|
|
||||||
android:text="@string/destination"
|
android:text="@string/destination"
|
||||||
android:textSize="15sp"></TextView>
|
android:textSize="15sp"></TextView>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user