0

Is it possible to implement a searchview widget to search from textview. My textview looks like this

TextView TextView TextView

and I inflate these 3 textviews using layout inflater to show multiple values from a fragment.

Fragment Class

public class MainFragment extends Fragment {
public View onCreateView (LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
    // set the layout and inflater

    //perform some operations for button click
    return view;
}

Activity class

public class MainActivity extends FragmentActivity{

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
            .add(R.id.container, new MainFragment()).commit();
    }
}

public boolean onOptionsItemSelected(MenuItem item) {
    //do some operations with overflow menu
}

public  ArrayList<Asset> getData() {
    //perform operations so that data can be sorted to an array and then passed to textviews
}

I am confused as to where to include the searchview widget and how to make the textview searchable..

Larry Schiefer
  • 15,687
  • 2
  • 27
  • 33
user3747512
  • 203
  • 1
  • 6
  • 15

1 Answers1

0

you can include the search view widget in on-create method and you can follows these links to get your code :) please visist this : How to set edittext to show search button or enter button on keyboard? and also visist this : Android: Edittext acting as search engine i hope this will help you to find your answer thanks...:)

Community
  • 1
  • 1
Sardar Khan
  • 845
  • 6
  • 16
  • Thanks for the useful links, I still have a question on how to configure the search action to only search for values in my array/textview alone! I saw examples of including the search in the action bar, but I want it to be present only in one layout where I am searching for the textview results – user3747512 Jul 15 '14 at 11:11
  • you can apply filter in your adapter these above links show how to filter adapter on specific text..thanks – Sardar Khan Mar 10 '17 at 05:31