Add swap button to route form

This commit is contained in:
Doug Keen 2016-11-02 18:34:42 -07:00
parent 44b1a1983a
commit 756545d491
7 changed files with 24 additions and 4 deletions

View File

@ -14,6 +14,8 @@ import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Spinner;
import android.widget.Toast;
@ -80,6 +82,16 @@ public abstract class AbstractRouteSelectionFragment extends DialogFragment {
.findViewById(R.id.destination_spinner);
destinationSpinner.setAdapter(destinationSpinnerAdapter);
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 924 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -38,16 +38,25 @@
android:text="@string/origin"
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
android:id="@+id/destination_spinner"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/origin_spinner"
android:layout_below="@+id/swap_button"
android:drawSelectorOnTop="true"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="15dip"
/>
<TextView
@ -56,11 +65,10 @@
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/destination_spinner"
android:layout_alignParentLeft="true"
android:layout_below="@+id/origin_spinner"
android:layout_below="@+id/swap_button"
android:gravity="center_vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="15dip"
android:text="@string/destination"
android:textSize="15sp"></TextView>