Wie Sie eine Suche auf ein action-bar?
Hier ist meine XML-Datei:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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"
android:background="#E0E0E0"
android:fitsSystemWindows="true"
tools:context="com.ccb.lldm.lldmhimnario.Cantos">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:elevation="25dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimaryDark"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_cantos" />
</android.support.design.widget.CoordinatorLayout>
Hier ist mein Java:
public class Cantos extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cantos);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setLogo(R.mipmap.ic_launcher);
toolbar.setTitle("Cantos");
toolbar.setTitleTextColor(getColor(R.color.colorPrimary));
}
}
Ich Frage mich, wie Sie eine Suche auf meine action bar. Also, wenn ich die Zeichen, Namen/Objekte kommen. Vielen Dank im Voraus. (Ist meine XML-Datei korrekt zu?)
Du musst angemeldet sein, um einen Kommentar abzugeben.
Hinzufügen einer such-anzeigen ist eigentlich sehr einfach, in Android, wie es hat eingebaute Unterstützung für Sie. Gehen Sie durch die Suche Ansicht die Funktionalität von android für weitere Einzelheiten.
http://developer.android.com/guide/topics/search/search-dialog.html
Besuchen Sie folgenden link, finden Sie die einfachste Möglichkeit zum implementieren von searchview in der action bar
http://javapapers.com/android/android-searchview-action-bar-tutorial/