webview - Android Toolbar in webapp -
i developing web app, , here have problem.
i have tool bar(android widget toolbar) logo , search button
as can see have login page(webview). want user see search button after users login webpage. how should that?
edited:
in toolbar.xml
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/my_toolbar" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="#000000" android:elevation="3dp" app:theme="@style/themeoverlay.appcompat.dark.actionbar" app:popuptheme="@style/themeoverlay.appcompat.light"> </android.support.v7.widget.toolbar>
in menu_main.xml
<?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=".mainactivity"> <item android:id="@+id/action_search" android:orderincategory="200" android:title="@string/action_search" android:icon="@drawable/ic_action_search" app:showasaction="ifroom|collapseactionview" app:actionviewclass="android.support.v7.widget.searchview"/> </menu>
and in mainactivity.java oncreate,
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar = (toolbar) findviewbyid(r.id.tool_bar); setsupportactionbar(toolbar); getsupportactionbar().setdisplayshowtitleenabled(false); //toolbar.setnavigationicon(r.mipmap.logo9); toolbar.settitle(""); toolbar.setsubtitle("");
......
@override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.menu_main, menu); searchview searchview = (searchview) menu.finditem(r.id.action_search).getactionview(); searchmanager searchmanager = (searchmanager) getsystemservice(search_service); searchview.setsearchableinfo(searchmanager.getsearchableinfo(getcomponentname())); return super.oncreateoptionsmenu(menu); }
and in activity_main.xml, include toolbar,
<include android:id="@+id/tool_bar" layout="@layout/tool_bar" ></include>
if search button android view
, can hide calling view.setvisibility(view.gone)
.
if have instead defined menu
xml resource , loaded in activity
, don't load menu
resource unless user logged in. done in public boolean oncreateoptionsmenu(menu menu)
of activity
.
if go activity
after logging in, use separate toolbar
there, icon here, without 1 in login activity
.
please provide more information on how added search icon toolbar
in first place, able more.
edit:
you can use webview.geturl()
method url of displayed website, if login page on login.php
, can if url that, , not show search icon. example can check url string.contains()
, like: .contains("login.php")
. , if true don't show button.
Comments
Post a Comment