Bug 1038789 - Add clear button to search bar in search activity. r=eedens

This commit is contained in:
Margaret Leibovic 2014-07-15 14:07:55 -07:00
parent 1161a46c30
commit 67fee7bd84
5 changed files with 26 additions and 4 deletions

View File

@ -19,6 +19,7 @@ import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ListView;
@ -30,7 +31,6 @@ import org.mozilla.search.R;
* A fragment to handle autocomplete. Its interface with the outside
* world should be very very limited.
* <p/>
* TODO: Add clear button to search input
* TODO: Add more search providers (other than the dictionary)
*/
public class SearchFragment extends Fragment implements AdapterView.OnItemClickListener,
@ -95,6 +95,14 @@ public class SearchFragment extends Fragment implements AdapterView.OnItemClickL
}
});
final Button clearButton = (Button) mainView.findViewById(R.id.clear_button);
clearButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
searchBar.setText("");
}
});
backdropFrame.setOnClickListener(new BackdropClickListener());
autoCompleteAdapter = new AutoCompleteAdapter(getActivity(), this);

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

View File

@ -25,9 +25,23 @@
android:orientation="vertical"
>
<EditText
android:id="@+id/auto_complete_search_bar"
style="@style/AutoCompleteEditText"/>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/auto_complete_search_bar"
style="@style/AutoCompleteEditText"/>
<Button
android:id="@+id/clear_button"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="3dp"
android:background="@drawable/search_clear" />
</FrameLayout>
<ListView
android:id="@+id/auto_complete_dropdown"