简体   繁体   中英

Android: finish activity when perform a search on SearchView

I have a simple searchview to perfom search functions and but I want when someone search something to finish the current activity where the searchview is placed and add and a Transition effect and then open the activity with the results. But I can't find a way to do it. Thank you :)

There's a pretty good starting guide here: http://developer.android.com/guide/topics/search/search-dialog.html . This one here is a bit more advanced: Implementing SearchView in action bar .

you can override the startActivty(Intent intent) method in your activity which has searchview.

@Override
public void startActivity(Intent intent) {
    finish();
    super.startActivity(intent);
    overridePendingTransition(R.anim.abc_slide_in_bottom, R.anim.abc_slide_out_top);
}

It worked for me. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM