Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What differences between android:actionViewClass and app:actionViewClass?

See below menu xml file,

<?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">
<item android:title="Search"
    android:id="@+id/search_menu"
    android:icon="@android:drawable/ic_menu_search"
    app:actionViewClass="android.widget.SearchView"
    app:showAsAction="always"/>

That let me confused, if using android:actionViewClass, I will get error like searchview is null, but using app:actionViewClass, everything seems fine. So I am wondering why and differences between android:actionViewClass and app:actionViewClass.

like image 515
Leon Avatar asked Jun 02 '17 05:06

Leon


People also ask

What is the difference between Android and app?

android is usually used for attribute coming from Android SDK itself. app is often used if you are using the support library. You may also see other namespaces if you are using custom views (of your own or form a library).

What is Actionview Android?

An action view is an action that provides rich functionality within the app bar. For example, a search action view allows the user to type their search text in the app bar, without having to change activities or fragments. An action provider is an action with its own customized layout.

What is showAsAction in Android?

android:showAsAction Keyword. When and how this item should appear as an action item in the app bar. A menu item can appear as an action item only when the activity includes an app bar. Valid values: Value.


1 Answers

android is usually used for attribute coming from Android SDK itself.

app is often used if you are using the support library.

You may also see other namespaces if you are using custom views (of your own or form a library). ref:-Difference between android: and app: prefix in Android XML?

like image 111
Vishal kumar singhvi Avatar answered Nov 14 '22 18:11

Vishal kumar singhvi