How to do a double search in android?

I am creating an Android application where the user selects the maximum value using a search.

I need another button on the same search screen so that the user can select the maximum and minimum value from a specific unique search key.

Here is my single search string code -

package com.ui.yogeshblogspot; public class CustomSeekBarExActivity extends Activity implements OnSeekBarChangeListener{ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SeekBar bar=(SeekBar)findViewById(R.id.seekBar1); bar.setOnSeekBarChangeListener(this); } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub TextView tv=(TextView)findViewById(R.id.textView2); tv.setText(Integer.toString(progress)+"%"); } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } } 

Here is my xml of the search bar -

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#FFFFFF"> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Choose Your Progress" android:textColor="#000000" android:textAppearance="?android:attr/textAppearanceMedium" /> <SeekBar android:id="@+id/seekBar1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:progressDrawable="@xml/progress" android:max="100" android:thumb="@xml/thumb"/> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:gravity="center" android:layout_gravity="center" android:paddingTop="10dp" android:textAppearance="?android:attr/textAppearanceMedium" /> </LinearLayout> 
+6
source share
5 answers

The Android widget class library has only one slider control, a search bar with one thumb control. Did some research on the Internet and found this cool custom widget, search-search range.

You can follow any of the below

https://github.com/edmodo/range-bar

https://code.google.com/p/range-seek-bar/

https://github.com/Larpon/RangeSeekBar

+11
source

Fully customize the two-way and one-way search arrow, you can provide the color of the thumb, etc. http://codingsignals.com/crystal-range-seekbar-in-android/

Add to your gradle

 dependencies { compile 'com.crystal:crystalrangeseekbar:1.0.0' } 

Two-way search bar

 <com.crystal.crystalrangeseekbar.widgets.BubbleThumbRangeSeekbar android:id="@+id/rangeSeekbar5" android:layout_width="match_parent" android:layout_height="wrap_content" app:corner_radius="10" app:min_value="0" app:max_value="100" app:steps="5" app:bar_color="#F7BB88" app:bar_highlight_color="#E07416" app:left_thumb_image="@drawable/thumb" app:right_thumb_image="@drawable/thumb" app:left_thumb_image_pressed="@drawable/thumb_pressed" app:right_thumb_image_pressed="@drawable/thumb_pressed" app:data_type="_integer"/> 
+9
source

enter image description here

From here

  <com.appyvet.rangebar.RangeBar xmlns:custom="http://schemas.android.com/apk/res-auto" android:id="@+id/SearchrangeSeekbarAge" android:layout_width="match_parent" android:layout_height="72dp" custom:tickStart="18" custom:tickInterval="1" custom:tickEnd="70" /> <com.appyvet.rangebar.RangeBar xmlns:custom="http://schemas.android.com/apk/res-auto" android:id="@+id/SearchrangeSeekbarHeight" android:layout_width="match_parent" android:layout_height="72dp" custom:tickStart="4.5" custom:tickInterval="0.10" custom:tickEnd="7.0" /> rangebar.setOnRangeBarChangeListener(new RangeBar.OnRangeBarChangeListener() { @Override public void onRangeChangeListener(RangeBar rangeBar, int leftPinIndex, int rightPinIndex, String leftPinValue, String rightPinValue) { } }); 
+3
source

You do not need to use two search bars, but you can perform the same minimum and maximum function using only one arrow with two thumbs above it. Here you can use its library https://code.google.com/p/range- seek-bar /

You can use using the code below

 private final Thumb getClosestThumb(float touchX) { double xValue = screenToNormalized(touchX); return (Math.abs(xValue - normalizedMinValue) < Math.abs(xValue - normalizedMaxValue)) ? Thumb.MIN : Thumb.MAX; } 

And in "public boolean onTouchEvent (MotionEvent event)",

 if(pressedThumb == null), pressedThumb = getClosestThumb(mDownMotionX); 
+2
source

RangeSeekBar https://github.com/RanaRanvijaySingh/RangeSeekBar . There are also other libraries available that offer many settings. If you want to switch to a more interactive design, find the Material Range Panel http://android-arsenal.com/details/1/1272 . enter image description here

0
source

Source: https://habr.com/ru/post/977959/


All Articles