-2
我遵循此link創建搜索界面。 但是,如果點擊編輯文本時如何開始搜索活動,但沒有關於菜單項的解釋。 我的界面是NoActionBarStyle如下圖所示的代碼和圖像如何在點擊編輯文本時啓動SearchActivity
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="perspective.secretbrowser.MainActivity">
<android.support.constraint.ConstraintLayout
android:layout_width="0dp"
android:layout_height="56dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="@color/colorPrimary"
tools:layout_constraintRight_creator="1"
tools:layout_constraintLeft_creator="1"
android:id="@+id/constraintLayout">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/menu_small"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:id="@+id/options"
android:visibility="visible"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp" />
<ImageView
android:id="@+id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/tabs_small"
android:visibility="visible"
android:scaleType="fitXY"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
app:layout_constraintRight_toLeftOf="@+id/options"
android:layout_marginRight="8dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp" />
<EditText
android:id="@+id/url_txt"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/url_bg"
android:hint="@string/search_hint"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/tabs"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.333"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
</android.support.constraint.ConstraintLayout>
<com.gc.materialdesign.views.ProgressBarDeterminate
android:id="@+id/progressBar"
android:layout_width="0dp"
android:layout_height="3dp"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="@+id/webView"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/constraintLayout" />
<WebView
android:id="@+id/webView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressBar" />
</android.support.constraint.ConstraintLayout>
建議我的代碼上的EditText