OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.payments.ui; | 5 package org.chromium.chrome.browser.payments.ui; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.view.LayoutInflater; | 8 import android.view.LayoutInflater; |
9 import android.view.View; | 9 import android.view.View; |
10 import android.view.ViewGroup; | 10 import android.view.ViewGroup; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 | 54 |
55 final List<DropdownKeyValue> dropdownKeyValues = mFieldModel.getDropdown KeyValues(); | 55 final List<DropdownKeyValue> dropdownKeyValues = mFieldModel.getDropdown KeyValues(); |
56 for (int j = 0; j < dropdownKeyValues.size(); j++) { | 56 for (int j = 0; j < dropdownKeyValues.size(); j++) { |
57 if (dropdownKeyValues.get(j).getKey().equals(mFieldModel.getValue()) ) { | 57 if (dropdownKeyValues.get(j).getKey().equals(mFieldModel.getValue()) ) { |
58 mSelectedIndex = j; | 58 mSelectedIndex = j; |
59 break; | 59 break; |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 ArrayAdapter<DropdownKeyValue> adapter = new ArrayAdapter<DropdownKeyVal ue>( | 63 ArrayAdapter<DropdownKeyValue> adapter = new ArrayAdapter<DropdownKeyVal ue>( |
64 context, android.R.layout.simple_spinner_item, dropdownKeyValues ); | 64 context, R.layout.multiline_spinner_item, dropdownKeyValues); |
65 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown _item); | 65 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown _item); |
66 | 66 |
67 mDropdown = (Spinner) mLayout.findViewById(R.id.spinner); | 67 mDropdown = (Spinner) mLayout.findViewById(R.id.spinner); |
please use gerrit instead
2016/08/26 16:46:15
How do you accomplish the folded dropdown look of
sebsg
2016/08/26 19:36:45
It's determined by the "multiline_spinner_item" re
| |
68 mDropdown.setTag(this); | 68 mDropdown.setTag(this); |
69 mDropdown.setContentDescription(mFieldModel.getLabel()); | 69 mDropdown.setContentDescription(mFieldModel.getLabel()); |
70 mDropdown.setAdapter(adapter); | 70 mDropdown.setAdapter(adapter); |
71 mDropdown.setSelection(mSelectedIndex); | 71 mDropdown.setSelection(mSelectedIndex); |
72 mDropdown.setOnItemSelectedListener(new OnItemSelectedListener() { | 72 mDropdown.setOnItemSelectedListener(new OnItemSelectedListener() { |
73 @Override | 73 @Override |
74 public void onItemSelected(AdapterView<?> parent, View view, int pos ition, long id) { | 74 public void onItemSelected(AdapterView<?> parent, View view, int pos ition, long id) { |
75 if (mSelectedIndex != position) { | 75 if (mSelectedIndex != position) { |
76 mSelectedIndex = position; | 76 mSelectedIndex = position; |
77 mFieldModel.setDropdownKey(dropdownKeyValues.get(position).g etKey(), | 77 mFieldModel.setDropdownKey(dropdownKeyValues.get(position).g etKey(), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 | 119 |
120 @Override | 120 @Override |
121 public void scrollToAndFocus() { | 121 public void scrollToAndFocus() { |
122 ViewGroup parent = (ViewGroup) mDropdown.getParent(); | 122 ViewGroup parent = (ViewGroup) mDropdown.getParent(); |
123 if (parent != null) parent.requestChildFocus(mDropdown, mDropdown); | 123 if (parent != null) parent.requestChildFocus(mDropdown, mDropdown); |
124 // Open the dropdown to prompt user selection. | 124 // Open the dropdown to prompt user selection. |
125 mDropdown.performClick(); | 125 mDropdown.performClick(); |
126 mDropdown.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED); | 126 mDropdown.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED); |
127 } | 127 } |
128 } | 128 } |
OLD | NEW |