我有这个应用程序,用户通过webview阅读文章。他可以阅读相关文章,然后按后退或按钮返回历史记录。有没有办法覆盖操作栏中的搜索小部件,以便通过startActivityForResult()或其他东西调用SearchResultsActivity?我希望用户点击文章并将该文章的链接传回webview以保持历史记录不变。
来自ArticleActivity的
<activity
android:name=".ArticleActivity"
android:label="@string/article"
android:parentActivityName=".CategoryActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="app.morningsignout.com.morningsignoff.CategoryActivity" />
</activity>
<activity
android:name=".SearchResultsActivity"
android:launchMode="singleTop"
android:label="@string/title_activity_search">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
来自清单
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="app.morningsignout.com.morningsignoff.ArticleActivity">
<item android:id="@+id/action_search"
android:title="@string/action_search"
android:icon="@android:drawable/ic_menu_search"
app:showAsAction="collapseActionView|ifRoom"
app:actionViewClass="android.support.v7.widget.SearchView"/>
</menu>
menu_article.xml
window.addEventListener('WebComponentsReady', function(e) {
console.log('components ready');
angular.bootstrap(document, 'app');
});