1
I’m building an app where in a particular app a list of registered users will appear in a ListView
. This Activity also has a SearchView
which serves to filter data from ListView
according to the written text. I would like to know how I can make this information filter.
Searchview xml code:
<android.support.v7.widget.CardView
android:id="@+id/sv_card_aux"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="60dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardBackgroundColor="@color/white_smoke"
app:cardCornerRadius="5dp"
app:cardUseCompatPadding="true">
<android.support.v7.widget.SearchView
android:id="@+id/sv_aux"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v7.widget.CardView>
Activity Code
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contas_auxiliares);
listaContasAux = (ListView) findViewById(R.id.listaAuxContas);
svContasAux = (SearchView) findViewById(R.id.sv_aux);
svCardContasAux = (CardView) findViewById(R.id.sv_card_aux);
svCardContasAux.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
svContasAux.setIconified(false);
}
});
}
Activity with the SearchView
:
NOTE: I tried to use a method to filter the search in Adapter, but could not, ag