the searchview appears on each listview row: Check the scrrenshot attached.
How can i make it apppear only once, at the top.
xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Home"
android:padding="30dp"
>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ED0316"
android:textSize="22sp"
android:fontFamily="sans-serif-condensed-light"
android:textColor="#fafafa"
android:id="@+id/txt" />
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- TODO: Update blank fragment layout -->
<SearchView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:queryHint="Search here..."
android:iconifiedByDefault="false"
android:focusedByDefault="t`enter code here`rue"
android:transitionName="Search_box"
android:id="@+id/search_view">
</SearchView>
</FrameLayout>
[enter image description here][1]
public class contractorAdapter extends ArrayAdapter { SearchView searchView; public contractorAdapter(@NonNull Context context, ArrayList ArrayList) { super(context, R.layout.fragment_home, ArrayList);
}
public static class ViewHolder {
SearchView searchView;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
searchView.setVisibility(position == 0 ? View.VISIBLE : View.GONE); // set it visible if it is at position 0. Else set it invisible
return convertView;
}