Skip to content

Commit 06dbf8f

Browse files
committed
Styles search autocomplete text and icon
1 parent 50d758d commit 06dbf8f

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

138 KB
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:id="@android:id/text1"
5+
android:layout_width="match_parent"
6+
android:layout_height="wrap_content"
7+
android:textAppearance="@style/MapzenItemTextAppearance"
8+
android:gravity="center_vertical"
9+
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
10+
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
11+
android:minHeight="?android:attr/listPreferredItemHeightSmall"
12+
android:drawableLeft="@drawable/ic_search_results_search" />

src/main/java/com/mapzen/search/AutoCompleteAdapter.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import android.content.Context;
1414
import android.database.Cursor;
1515
import android.database.MatrixCursor;
16+
import android.graphics.Typeface;
1617
import android.support.v4.app.FragmentManager;
1718
import android.view.LayoutInflater;
1819
import android.view.MotionEvent;
@@ -61,9 +62,13 @@ public void setMapFragment(MapFragment mapFragment) {
6162
@Override
6263
public View newView(final Context c, Cursor cursor, ViewGroup parent) {
6364
LayoutInflater inflater = LayoutInflater.from(c);
64-
View v = inflater.inflate(android.R.layout.simple_list_item_1, parent, false);
65-
assert v != null;
66-
v.setOnClickListener(new View.OnClickListener() {
65+
final TextView textView =
66+
(TextView) inflater.inflate(R.layout.search_dropdown_item, parent, false);
67+
final Typeface typeface = Typeface.createFromAsset(c.getAssets(),
68+
"fonts/RobotoCondensed-Light.ttf");
69+
textView.setTypeface(typeface);
70+
assert textView != null;
71+
textView.setOnClickListener(new View.OnClickListener() {
6772
@Override
6873
public void onClick(View view) {
6974
TextView tv = (TextView) view;
@@ -98,7 +103,7 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
98103
return false;
99104
}
100105
});
101-
return v;
106+
return textView;
102107
}
103108

104109
private void dismissKeyboard() {

0 commit comments

Comments
 (0)