I want to implement searchView like this link and link2 but I want to make a search from own EditText not in ActioBar or in menu.
I want to know what is the code in the main layout xml file. consider that I'm not want to use ActionBar with menu item because it isn't supported for api less that level 11, I want to use the search and get result in the same Activity, all what I want to know how can I get the search bar when press a button to give it a word t search in sqlite and get the result in the same Activity?
Hope anyone got my mean.
Thanks in advance.
Do not use a EditText, it is much easier to use a SearchView. If you don't want to have search interface in the action bar, then you can use a search widget, which is an instance of SearchView.
The basics are here : http://developer.android.com/guide/topics/search/search-dialog.html
If you really do not want the ActionBar and have to support older API levels than API level 11 (Honeycomb) and do not want to use a search dialog, you have to do everything on your own.
You could use a AutoCompleteTextView to display search suggestions and start an activity / fragment to display a list of results with the query entered whenever the user triggers your search. That's not different from any other Activity that has to react to user input.
But I strongly suggest to use ActionBarCompat and the support library to provide an ActionBar on older devices and use the SearchView within the ActionBar. That's what users expect nowadays anyway and it makes development that much easier.
If you want to create a search box using EditText (not in Action Bar), you may refer to the following XML code:
<RelativeLayout
android:id="#+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<EditText
android:id="#+id/inputSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:hint="Search...."
android:inputType="textCapCharacters" />
<ImageButton
android:id="#+id/searchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_menu_search" />
</RelativeLayout>
But, I would suggest use ActionBar for the search box, it would look neat and easier as well. For search box using ActionBar, you may refer the following link:
http://javapapers.com/android/android-searchview-action-bar-tutorial/
Related
This is how I want to show the value of the slider. Please find the picture
This is currently not supported, the available options in LabelFormatter (which can be applied to sliders with slider.setLabelFormatter(...) are:
LabelFormatter.LABEL_FLOATING: Label visible during interaction only
LabelFormatter.LABEL_WITHIN_BOUNDS: Label visible during interaction only
LabelFormatter.LABEL_GONE: Label never visible
You can find the code here with the extensive javadoc explanation.
You could open a feature request for this on the Material GitHub issues page
You can set the label behaviour "visible" in the XML file. So in the slider XML code, you just need to add
app:labelBehavior="visible"
Below I am attaching a sample XML code for the same.
<com.google.android.material.slider.Slider
android:id="#+id/seek_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:valueFrom="1"
android:valueTo="100"
android:layout_gravity="center"
android:layout_margin="15dp"
app:tickColor="#0000FF"
app:labelStyle="#style/Tooltip"
app:labelBehavior="visible"
/>
https://imgur.com/fmSVNhu Keyboard Spinner(?)
I've been using a Spinner in my application and the number of items that should be in the Spinner is a lot more than i thought and the spinner scroll bar is quite small already due to the number of items. I thought it'd look cleaner if I used this Keyboard Spinner just like the one in the image that I linked above where the keyboard turns into like a selection. But I don't know what it's called and how to replace the Spinner im using with it.
Sorry for bad english. I'm new to stackoverflow hope someone could help :)
What you posted is indeed native to iOS, this is a very bad choice design wise.
I would highly recommend to use Exposed Dropdown Menus from the new material components lib https://github.com/material-components/material-components-android/
This introduces a way to implement a "spinner" using a AutoCompleteTextView so users can type part of the input before selecting the item.
Here is an example of how that would look like:
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_text">
<AutoCompleteTextView
android:id="#+id/filled_exposed_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
More information can be found here:
https://material.io/develop/android/components/menu/
However if you INSIST on having that design there are some options here:
https://android-arsenal.com/tag/142 (WheelView or WheelPicker)
You can use a pre-maid one, like this
I want to add a search bar in my application, similar to what Zomato does. I have searched a lot and I have learnt search interface is the way to go, but everywhere I have seen it has been added in the action bar whereas I want it in some fragment(fixed activity). Is there any other way search could be added(how zomato does it)?
Is it necessary to open another activity to do the search or I could open another fragment to do the same?
Like #pskink said, you can add the SearchView anywhere in your layout, like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<SearchView
android:id="#+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</SearchView>
</LinearLayout>
I will be very thankfull if anyone will help me find out some details about customizing sherlock actionbar.
To be more concrete: I need an action bar with four buttons. Two small buttons on the sides of the bar (on on the left side and second on the right), and one "paired" radiobutton in the middle of the bar.
When I say "paired" I mean something like in iOS when there are two buttons positioned near each other and when I press one - the second is unpressed and vice versa.
All in all it should look like this.
Is it even possible to make this or I should forget about using the wonderful sherlock creature?
I would personally abandon the idea of using ActionBarSherlock and instead just implement this using your own layout resource.
As a user of ActionBarSherlock I can say it's a fantastic library, as it essentially allows you to use the ActionBar API across all devices, including pre-Honeycomb, meaning you don't have to code a separate UI to suit pre-Honeycomb device. But the point of ActionBarSherlock is that it just provides APIs that are equivalent to those of the native ActionBar. And the problem is that the ActionBar is restrictive in what you can creatively do with it, because it is designed to offer specific functionality and controls that kind of fit around how Google want you to implement your UI. In a nutshell, you can specify a custom layout View that appears somewhere within the bar. You can also control which menu items appear as action items placed on the right-hand side of the bar (though it is ultimately still up to the system, based on screen space, if such items are made visible on the bar). The bar also allows you to implement some very special functionality (Action Views, Action Providers, etc.)
But if you're looking to create a very customised layout like the one you've pictured, and you don't need the special functionality that the ActionBar (or ActionBarSherlock) provides, then you might be better off doing it from scratch.
Yes you can make your Sherlock ActionBar like you show above. you have to set custom View to your SherLock ActionBAr. Just few lines of code
getSupportActionBar()
.setDisplayShowCustomEnabled(true);
getSupportActionBar().setCustomView(
R.layout.your_custom_layout);
and you custom layout should be RelativeLayout something like this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="72dp" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="#drawable/icon" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/icon" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:src="#drawable/icon" />
</LinearLayout>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/icon" />
</RelativeLayout>
I'd like to add a Button like this one below into my ListView when the list is empty using the setEmptyView() method.
Is there a built-in style in Android for this? Because I noticed that a few apps are using exactly the same Button style.
Look at this link: Add Items to ListView - Android
It shows the correct Android resource to use, which shows a green "+" symbol on the ImageButton.
To be precise:
<ImageButton
android:id="#+id/moreImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:contentDescription="#string/image_button_delete"
android:src="#android:drawable/ic_input_add" />
Short answer: No, this is not a standard Button.
However, you can add a similar Button by using an ImageView. You just have to design/download something you like.