Chromium Code Reviews| Index: chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionArrayAdapter.java |
| diff --git a/chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionArrayAdapter.java b/chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionArrayAdapter.java |
| index fbd147f1e36fdbe0484a17ed3566067aca901dd1..23f1ecf65783250c3b301134215b4e0d042d440a 100644 |
| --- a/chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionArrayAdapter.java |
| +++ b/chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionArrayAdapter.java |
| @@ -10,6 +10,8 @@ import android.view.View; |
| import android.view.ViewGroup; |
| import android.widget.AbsListView.LayoutParams; |
| import android.widget.ArrayAdapter; |
| +import android.widget.EditText; |
| +import android.widget.ImageView; |
| import android.widget.TextView; |
| import org.chromium.chrome.browser.omnibox.OmniboxSuggestion; |
| @@ -22,10 +24,13 @@ import java.util.List; |
| */ |
| class SuggestionArrayAdapter extends ArrayAdapter<OmniboxSuggestion> { |
| private final List<OmniboxSuggestion> mSuggestions; |
| + private EditText mUrlTextView; |
| - public SuggestionArrayAdapter(Context context, int res, List<OmniboxSuggestion> suggestions) { |
| + public SuggestionArrayAdapter(Context context, int res, List<OmniboxSuggestion> suggestions, |
| + EditText urlTextView) { |
| super(context, res, suggestions); |
| mSuggestions = suggestions; |
| + mUrlTextView = urlTextView; |
| } |
| @Override |
| @@ -34,16 +39,26 @@ class SuggestionArrayAdapter extends ArrayAdapter<OmniboxSuggestion> { |
| if (v == null) { |
| LayoutInflater vi = (LayoutInflater) getContext().getSystemService( |
| Context.LAYOUT_INFLATER_SERVICE); |
| - v = vi.inflate(R.layout.dropdown_item, null); |
| + v = vi.inflate(R.layout.suggestion_item, null); |
| int height = getContext().getResources().getDimensionPixelSize( |
| R.dimen.dropdown_item_height); |
| v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, height)); |
| } |
| - TextView t1 = (TextView) v.findViewById(R.id.dropdown_label); |
| - t1.setText(mSuggestions.get(position).getDisplayText()); |
| + TextView t1 = (TextView) v.findViewById(R.id.suggestion_item_label); |
| + final String suggestionText = mSuggestions.get(position).getDisplayText(); |
| + t1.setText(suggestionText); |
|
Bernhard Bauer
2014/09/10 07:53:31
I think you could directly inline this.
ankit
2014/09/10 09:15:52
In onClickListener I am using the same variable su
Bernhard Bauer
2014/09/10 10:40:34
Oh, didn't see that. Okay, let's keep it as it is.
|
| - TextView t2 = (TextView) v.findViewById(R.id.dropdown_sublabel); |
| + TextView t2 = (TextView) v.findViewById(R.id.suggestion_item_sublabel); |
| t2.setText(mSuggestions.get(position).getUrl()); |
| + |
| + ImageView arrow = (ImageView) v.findViewById(R.id.suggestion_item_arrow); |
| + arrow.setOnClickListener(new View.OnClickListener() { |
| + @Override |
| + public void onClick(View v) { |
| + mUrlTextView.setText(suggestionText); |
| + mUrlTextView.setSelection(suggestionText.length()); |
| + } |
| + }); |
| return v; |
| } |
| } |