1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436
|
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.app;
import android.annotation.DrawableRes;
import android.annotation.IntDef;
import android.annotation.LayoutRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringRes;
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.view.ViewHierarchyEncoder;
import android.view.Window;
import android.view.inspector.InspectableProperty;
import android.widget.SpinnerAdapter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* A primary toolbar within the activity that may display the activity title, application-level
* navigation affordances, and other interactive items.
*
* <p>Beginning with Android 3.0 (API level 11), the action bar appears at the top of an
* activity's window when the activity uses the system's {@link
* android.R.style#Theme_Holo Holo} theme (or one of its descendant themes), which is the default.
* You may otherwise add the action bar by calling {@link
* android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR)} or by declaring it in a
* custom theme with the {@link android.R.styleable#Theme_windowActionBar windowActionBar} property.
* </p>
*
* <p>Beginning with Android L (API level 21), the action bar may be represented by any
* Toolbar widget within the application layout. The application may signal to the Activity
* which Toolbar should be treated as the Activity's action bar. Activities that use this
* feature should use one of the supplied <code>.NoActionBar</code> themes, set the
* {@link android.R.styleable#Theme_windowActionBar windowActionBar} attribute to <code>false</code>
* or otherwise not request the window feature.</p>
*
* <p>By adjusting the window features requested by the theme and the layouts used for
* an Activity's content view, an app can use the standard system action bar on older platform
* releases and the newer inline toolbars on newer platform releases. The <code>ActionBar</code>
* object obtained from the Activity can be used to control either configuration transparently.</p>
*
* <p>When using the Holo themes the action bar shows the application icon on
* the left, followed by the activity title. If your activity has an options menu, you can make
* select items accessible directly from the action bar as "action items". You can also
* modify various characteristics of the action bar or remove it completely.</p>
*
* <p>When using the Material themes (default in API 21 or newer) the navigation button
* (formerly "Home") takes over the space previously occupied by the application icon.
* Apps wishing to express a stronger branding should use their brand colors heavily
* in the action bar and other application chrome or use a {@link #setLogo(int) logo}
* in place of their standard title text.</p>
*
* <p>From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link
* android.app.Activity#getActionBar getActionBar()}.</p>
*
* <p>In some cases, the action bar may be overlayed by another bar that enables contextual actions,
* using an {@link android.view.ActionMode}. For example, when the user selects one or more items in
* your activity, you can enable an action mode that offers actions specific to the selected
* items, with a UI that temporarily replaces the action bar. Although the UI may occupy the
* same space, the {@link android.view.ActionMode} APIs are distinct and independent from those for
* {@link ActionBar}.</p>
*
* <div class="special reference">
* <h3>Developer Guides</h3>
* <p>For information about how to use the action bar, including how to add action items, navigation
* modes and more, read the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action
* Bar</a> developer guide.</p>
* </div>
*/
public abstract class ActionBar {
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = { "NAVIGATION_MODE_" }, value = {
NAVIGATION_MODE_STANDARD,
NAVIGATION_MODE_LIST,
NAVIGATION_MODE_TABS
})
public @interface NavigationMode {}
/**
* Standard navigation mode. Consists of either a logo or icon
* and title text with an optional subtitle. Clicking any of these elements
* will dispatch onOptionsItemSelected to the host Activity with
* a MenuItem with item ID android.R.id.home.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public static final int NAVIGATION_MODE_STANDARD = 0;
/**
* List navigation mode. Instead of static title text this mode
* presents a list menu for navigation within the activity.
* e.g. this might be presented to the user as a dropdown list.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public static final int NAVIGATION_MODE_LIST = 1;
/**
* Tab navigation mode. Instead of static title text this mode
* presents a series of tabs for navigation within the activity.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public static final int NAVIGATION_MODE_TABS = 2;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(flag = true, prefix = { "DISPLAY_" }, value = {
DISPLAY_USE_LOGO,
DISPLAY_SHOW_HOME,
DISPLAY_HOME_AS_UP,
DISPLAY_SHOW_TITLE,
DISPLAY_SHOW_CUSTOM,
DISPLAY_TITLE_MULTIPLE_LINES
})
public @interface DisplayOptions {}
/**
* Use logo instead of icon if available. This flag will cause appropriate
* navigation modes to use a wider logo in place of the standard icon.
*
* @see #setDisplayOptions(int)
* @see #setDisplayOptions(int, int)
*/
public static final int DISPLAY_USE_LOGO = 0x1;
/**
* Show 'home' elements in this action bar, leaving more space for other
* navigation elements. This includes logo and icon.
*
* @see #setDisplayOptions(int)
* @see #setDisplayOptions(int, int)
*/
public static final int DISPLAY_SHOW_HOME = 0x2;
/**
* Display the 'home' element such that it appears as an 'up' affordance.
* e.g. show an arrow to the left indicating the action that will be taken.
*
* Set this flag if selecting the 'home' button in the action bar to return
* up by a single level in your UI rather than back to the top level or front page.
*
* <p>Setting this option will implicitly enable interaction with the home/up
* button. See {@link #setHomeButtonEnabled(boolean)}.
*
* @see #setDisplayOptions(int)
* @see #setDisplayOptions(int, int)
*/
public static final int DISPLAY_HOME_AS_UP = 0x4;
/**
* Show the activity title and subtitle, if present.
*
* @see #setTitle(CharSequence)
* @see #setTitle(int)
* @see #setSubtitle(CharSequence)
* @see #setSubtitle(int)
* @see #setDisplayOptions(int)
* @see #setDisplayOptions(int, int)
*/
public static final int DISPLAY_SHOW_TITLE = 0x8;
/**
* Show the custom view if one has been set.
* @see #setCustomView(View)
* @see #setDisplayOptions(int)
* @see #setDisplayOptions(int, int)
*/
public static final int DISPLAY_SHOW_CUSTOM = 0x10;
/**
* Allow the title to wrap onto multiple lines if space is available
* @hide pending API approval
*/
@UnsupportedAppUsage
public static final int DISPLAY_TITLE_MULTIPLE_LINES = 0x20;
/**
* Set the action bar into custom navigation mode, supplying a view
* for custom navigation.
*
* Custom navigation views appear between the application icon and
* any action buttons and may use any space available there. Common
* use cases for custom navigation views might include an auto-suggesting
* address bar for a browser or other navigation mechanisms that do not
* translate well to provided navigation modes.
*
* @param view Custom navigation view to place in the ActionBar.
*/
public abstract void setCustomView(View view);
/**
* Set the action bar into custom navigation mode, supplying a view
* for custom navigation.
*
* <p>Custom navigation views appear between the application icon and
* any action buttons and may use any space available there. Common
* use cases for custom navigation views might include an auto-suggesting
* address bar for a browser or other navigation mechanisms that do not
* translate well to provided navigation modes.</p>
*
* <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
* the custom view to be displayed.</p>
*
* @param view Custom navigation view to place in the ActionBar.
* @param layoutParams How this custom view should layout in the bar.
*
* @see #setDisplayOptions(int, int)
*/
public abstract void setCustomView(View view, LayoutParams layoutParams);
/**
* Set the action bar into custom navigation mode, supplying a view
* for custom navigation.
*
* <p>Custom navigation views appear between the application icon and
* any action buttons and may use any space available there. Common
* use cases for custom navigation views might include an auto-suggesting
* address bar for a browser or other navigation mechanisms that do not
* translate well to provided navigation modes.</p>
*
* <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
* the custom view to be displayed.</p>
*
* @param resId Resource ID of a layout to inflate into the ActionBar.
*
* @see #setDisplayOptions(int, int)
*/
public abstract void setCustomView(@LayoutRes int resId);
/**
* Set the icon to display in the 'home' section of the action bar.
* The action bar will use an icon specified by its style or the
* activity icon by default.
*
* Whether the home section shows an icon or logo is controlled
* by the display option {@link #DISPLAY_USE_LOGO}.
*
* @param resId Resource ID of a drawable to show as an icon.
*
* @see #setDisplayUseLogoEnabled(boolean)
* @see #setDisplayShowHomeEnabled(boolean)
*/
public abstract void setIcon(@DrawableRes int resId);
/**
* Set the icon to display in the 'home' section of the action bar.
* The action bar will use an icon specified by its style or the
* activity icon by default.
*
* Whether the home section shows an icon or logo is controlled
* by the display option {@link #DISPLAY_USE_LOGO}.
*
* @param icon Drawable to show as an icon.
*
* @see #setDisplayUseLogoEnabled(boolean)
* @see #setDisplayShowHomeEnabled(boolean)
*/
public abstract void setIcon(Drawable icon);
/**
* Set the logo to display in the 'home' section of the action bar.
* The action bar will use a logo specified by its style or the
* activity logo by default.
*
* Whether the home section shows an icon or logo is controlled
* by the display option {@link #DISPLAY_USE_LOGO}.
*
* @param resId Resource ID of a drawable to show as a logo.
*
* @see #setDisplayUseLogoEnabled(boolean)
* @see #setDisplayShowHomeEnabled(boolean)
*/
public abstract void setLogo(@DrawableRes int resId);
/**
* Set the logo to display in the 'home' section of the action bar.
* The action bar will use a logo specified by its style or the
* activity logo by default.
*
* Whether the home section shows an icon or logo is controlled
* by the display option {@link #DISPLAY_USE_LOGO}.
*
* @param logo Drawable to show as a logo.
*
* @see #setDisplayUseLogoEnabled(boolean)
* @see #setDisplayShowHomeEnabled(boolean)
*/
public abstract void setLogo(Drawable logo);
/**
* Set the adapter and navigation callback for list navigation mode.
*
* The supplied adapter will provide views for the expanded list as well as
* the currently selected item. (These may be displayed differently.)
*
* The supplied OnNavigationListener will alert the application when the user
* changes the current list selection.
*
* @param adapter An adapter that will provide views both to display
* the current navigation selection and populate views
* within the dropdown navigation menu.
* @param callback An OnNavigationListener that will receive events when the user
* selects a navigation item.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract void setListNavigationCallbacks(SpinnerAdapter adapter,
OnNavigationListener callback);
/**
* Set the selected navigation item in list or tabbed navigation modes.
*
* @param position Position of the item to select.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract void setSelectedNavigationItem(int position);
/**
* Get the position of the selected navigation item in list or tabbed navigation modes.
*
* @return Position of the selected item.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract int getSelectedNavigationIndex();
/**
* Get the number of navigation items present in the current navigation mode.
*
* @return Number of navigation items.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract int getNavigationItemCount();
/**
* Set the action bar's title. This will only be displayed if
* {@link #DISPLAY_SHOW_TITLE} is set.
*
* @param title Title to set
*
* @see #setTitle(int)
* @see #setDisplayOptions(int, int)
*/
public abstract void setTitle(CharSequence title);
/**
* Set the action bar's title. This will only be displayed if
* {@link #DISPLAY_SHOW_TITLE} is set.
*
* @param resId Resource ID of title string to set
*
* @see #setTitle(CharSequence)
* @see #setDisplayOptions(int, int)
*/
public abstract void setTitle(@StringRes int resId);
/**
* Set the action bar's subtitle. This will only be displayed if
* {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the
* subtitle entirely.
*
* @param subtitle Subtitle to set
*
* @see #setSubtitle(int)
* @see #setDisplayOptions(int, int)
*/
public abstract void setSubtitle(CharSequence subtitle);
/**
* Set the action bar's subtitle. This will only be displayed if
* {@link #DISPLAY_SHOW_TITLE} is set.
*
* @param resId Resource ID of subtitle string to set
*
* @see #setSubtitle(CharSequence)
* @see #setDisplayOptions(int, int)
*/
public abstract void setSubtitle(@StringRes int resId);
/**
* Set display options. This changes all display option bits at once. To change
* a limited subset of display options, see {@link #setDisplayOptions(int, int)}.
*
* @param options A combination of the bits defined by the DISPLAY_ constants
* defined in ActionBar.
*/
public abstract void setDisplayOptions(@DisplayOptions int options);
/**
* Set selected display options. Only the options specified by mask will be changed.
* To change all display option bits at once, see {@link #setDisplayOptions(int)}.
*
* <p>Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the
* {@link #DISPLAY_SHOW_HOME} option.
* setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO)
* will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}.
*
* @param options A combination of the bits defined by the DISPLAY_ constants
* defined in ActionBar.
* @param mask A bit mask declaring which display options should be changed.
*/
public abstract void setDisplayOptions(@DisplayOptions int options, @DisplayOptions int mask);
/**
* Set whether to display the activity logo rather than the activity icon.
* A logo is often a wider, more detailed image.
*
* <p>To set several display options at once, see the setDisplayOptions methods.
*
* @param useLogo true to use the activity logo, false to use the activity icon.
*
* @see #setDisplayOptions(int)
* @see #setDisplayOptions(int, int)
*/
public abstract void setDisplayUseLogoEnabled(boolean useLogo);
/**
* Set whether to include the application home affordance in the action bar.
* Home is presented as either an activity icon or logo.
*
* <p>To set several display options at once, see the setDisplayOptions methods.
*
* @param showHome true to show home, false otherwise.
*
* @see #setDisplayOptions(int)
* @see #setDisplayOptions(int, int)
*/
public abstract void setDisplayShowHomeEnabled(boolean showHome);
/**
* Set whether home should be displayed as an "up" affordance.
* Set this to true if selecting "home" returns up by a single level in your UI
* rather than back to the top level or front page.
*
* <p>To set several display options at once, see the setDisplayOptions methods.
*
* @param showHomeAsUp true to show the user that selecting home will return one
* level up rather than to the top level of the app.
*
* @see #setDisplayOptions(int)
* @see #setDisplayOptions(int, int)
*/
public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
/**
* Set whether an activity title/subtitle should be displayed.
*
* <p>To set several display options at once, see the setDisplayOptions methods.
*
* @param showTitle true to display a title/subtitle if present.
*
* @see #setDisplayOptions(int)
* @see #setDisplayOptions(int, int)
*/
public abstract void setDisplayShowTitleEnabled(boolean showTitle);
/**
* Set whether a custom view should be displayed, if set.
*
* <p>To set several display options at once, see the setDisplayOptions methods.
*
* @param showCustom true if the currently set custom view should be displayed, false otherwise.
*
* @see #setDisplayOptions(int)
* @see #setDisplayOptions(int, int)
*/
public abstract void setDisplayShowCustomEnabled(boolean showCustom);
/**
* Set the ActionBar's background. This will be used for the primary
* action bar.
*
* @param d Background drawable
* @see #setStackedBackgroundDrawable(Drawable)
* @see #setSplitBackgroundDrawable(Drawable)
*/
public abstract void setBackgroundDrawable(@Nullable Drawable d);
/**
* Set the ActionBar's stacked background. This will appear
* in the second row/stacked bar on some devices and configurations.
*
* @param d Background drawable for the stacked row
*/
public void setStackedBackgroundDrawable(Drawable d) { }
/**
* Set the ActionBar's split background. This will appear in
* the split action bar containing menu-provided action buttons
* on some devices and configurations.
* <p>You can enable split action bar with {@link android.R.attr#uiOptions}
*
* @param d Background drawable for the split bar
*/
public void setSplitBackgroundDrawable(Drawable d) { }
/**
* @return The current custom view.
*/
public abstract View getCustomView();
/**
* Returns the current ActionBar title in standard mode.
* Returns null if {@link #getNavigationMode()} would not return
* {@link #NAVIGATION_MODE_STANDARD}.
*
* @return The current ActionBar title or null.
*/
public abstract CharSequence getTitle();
/**
* Returns the current ActionBar subtitle in standard mode.
* Returns null if {@link #getNavigationMode()} would not return
* {@link #NAVIGATION_MODE_STANDARD}.
*
* @return The current ActionBar subtitle or null.
*/
public abstract CharSequence getSubtitle();
/**
* Returns the current navigation mode. The result will be one of:
* <ul>
* <li>{@link #NAVIGATION_MODE_STANDARD}</li>
* <li>{@link #NAVIGATION_MODE_LIST}</li>
* <li>{@link #NAVIGATION_MODE_TABS}</li>
* </ul>
*
* @return The current navigation mode.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
@NavigationMode
public abstract int getNavigationMode();
/**
* Set the current navigation mode.
*
* @param mode The new mode to set.
* @see #NAVIGATION_MODE_STANDARD
* @see #NAVIGATION_MODE_LIST
* @see #NAVIGATION_MODE_TABS
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract void setNavigationMode(@NavigationMode int mode);
/**
* @return The current set of display options.
*/
public abstract int getDisplayOptions();
/**
* Create and return a new {@link Tab}.
* This tab will not be included in the action bar until it is added.
*
* <p>Very often tabs will be used to switch between {@link Fragment}
* objects. Here is a typical implementation of such tabs:</p>
*
* {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java
* complete}
*
* @return A new Tab
*
* @see #addTab(Tab)
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract Tab newTab();
/**
* Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
* If this is the first tab to be added it will become the selected tab.
*
* @param tab Tab to add
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract void addTab(Tab tab);
/**
* Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
*
* @param tab Tab to add
* @param setSelected True if the added tab should become the selected tab.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract void addTab(Tab tab, boolean setSelected);
/**
* Add a tab for use in tabbed navigation mode. The tab will be inserted at
* <code>position</code>. If this is the first tab to be added it will become
* the selected tab.
*
* @param tab The tab to add
* @param position The new position of the tab
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract void addTab(Tab tab, int position);
/**
* Add a tab for use in tabbed navigation mode. The tab will be insterted at
* <code>position</code>.
*
* @param tab The tab to add
* @param position The new position of the tab
* @param setSelected True if the added tab should become the selected tab.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract void addTab(Tab tab, int position, boolean setSelected);
/**
* Remove a tab from the action bar. If the removed tab was selected it will be deselected
* and another tab will be selected if present.
*
* @param tab The tab to remove
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract void removeTab(Tab tab);
/**
* Remove a tab from the action bar. If the removed tab was selected it will be deselected
* and another tab will be selected if present.
*
* @param position Position of the tab to remove
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract void removeTabAt(int position);
/**
* Remove all tabs from the action bar and deselect the current tab.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract void removeAllTabs();
/**
* Select the specified tab. If it is not a child of this action bar it will be added.
*
* <p>Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.</p>
*
* @param tab Tab to select
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract void selectTab(Tab tab);
/**
* Returns the currently selected tab if in tabbed navigation mode and there is at least
* one tab present.
*
* @return The currently selected tab or null
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract Tab getSelectedTab();
/**
* Returns the tab at the specified index.
*
* @param index Index value in the range 0-get
* @return
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract Tab getTabAt(int index);
/**
* Returns the number of tabs currently registered with the action bar.
* @return Tab count
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public abstract int getTabCount();
/**
* Retrieve the current height of the ActionBar.
*
* @return The ActionBar's height
*/
public abstract int getHeight();
/**
* Show the ActionBar if it is not currently showing.
* If the window hosting the ActionBar does not have the feature
* {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
* content to fit the new space available.
*
* <p>If you are hiding the ActionBar through
* {@link View#SYSTEM_UI_FLAG_FULLSCREEN View.SYSTEM_UI_FLAG_FULLSCREEN},
* you should not call this function directly.
*/
public abstract void show();
/**
* Hide the ActionBar if it is currently showing.
* If the window hosting the ActionBar does not have the feature
* {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
* content to fit the new space available.
*
* <p>Instead of calling this function directly, you can also cause an
* ActionBar using the overlay feature to hide through
* {@link View#SYSTEM_UI_FLAG_FULLSCREEN View.SYSTEM_UI_FLAG_FULLSCREEN}.
* Hiding the ActionBar through this system UI flag allows you to more
* seamlessly hide it in conjunction with other screen decorations.
*/
public abstract void hide();
/**
* @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise.
*/
public abstract boolean isShowing();
/**
* Add a listener that will respond to menu visibility change events.
*
* @param listener The new listener to add
*/
public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener);
/**
* Remove a menu visibility listener. This listener will no longer receive menu
* visibility change events.
*
* @param listener A listener to remove that was previously added
*/
public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener);
/**
* Enable or disable the "home" button in the corner of the action bar. (Note that this
* is the application home/up affordance on the action bar, not the systemwide home
* button.)
*
* <p>This defaults to true for packages targeting < API 14. For packages targeting
* API 14 or greater, the application should call this method to enable interaction
* with the home/up affordance.
*
* <p>Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable
* the home button.
*
* @param enabled true to enable the home button, false to disable the home button.
*/
public void setHomeButtonEnabled(boolean enabled) { }
/**
* Returns a {@link Context} with an appropriate theme for creating views that
* will appear in the action bar. If you are inflating or instantiating custom views
* that will appear in an action bar, you should use the Context returned by this method.
* (This includes adapters used for list navigation mode.)
* This will ensure that views contrast properly against the action bar.
*
* @return A themed Context for creating views
*/
public Context getThemedContext() { return null; }
/**
* Returns true if the Title field has been truncated during layout for lack
* of available space.
*
* @return true if the Title field has been truncated
* @hide pending API approval
*/
public boolean isTitleTruncated() { return false; }
/**
* Set an alternate drawable to display next to the icon/logo/title
* when {@link #DISPLAY_HOME_AS_UP} is enabled. This can be useful if you are using
* this mode to display an alternate selection for up navigation, such as a sliding drawer.
*
* <p>If you pass <code>null</code> to this method, the default drawable from the theme
* will be used.</p>
*
* <p>If you implement alternate or intermediate behavior around Up, you should also
* call {@link #setHomeActionContentDescription(int) setHomeActionContentDescription()}
* to provide a correct description of the action for accessibility support.</p>
*
* @param indicator A drawable to use for the up indicator, or null to use the theme's default
*
* @see #setDisplayOptions(int, int)
* @see #setDisplayHomeAsUpEnabled(boolean)
* @see #setHomeActionContentDescription(int)
*/
public void setHomeAsUpIndicator(Drawable indicator) { }
/**
* Set an alternate drawable to display next to the icon/logo/title
* when {@link #DISPLAY_HOME_AS_UP} is enabled. This can be useful if you are using
* this mode to display an alternate selection for up navigation, such as a sliding drawer.
*
* <p>If you pass <code>0</code> to this method, the default drawable from the theme
* will be used.</p>
*
* <p>If you implement alternate or intermediate behavior around Up, you should also
* call {@link #setHomeActionContentDescription(int) setHomeActionContentDescription()}
* to provide a correct description of the action for accessibility support.</p>
*
* @param resId Resource ID of a drawable to use for the up indicator, or null
* to use the theme's default
*
* @see #setDisplayOptions(int, int)
* @see #setDisplayHomeAsUpEnabled(boolean)
* @see #setHomeActionContentDescription(int)
*/
public void setHomeAsUpIndicator(@DrawableRes int resId) { }
/**
* Set an alternate description for the Home/Up action, when enabled.
*
* <p>This description is commonly used for accessibility/screen readers when
* the Home action is enabled. (See {@link #setDisplayHomeAsUpEnabled(boolean)}.)
* Examples of this are, "Navigate Home" or "Navigate Up" depending on the
* {@link #DISPLAY_HOME_AS_UP} display option. If you have changed the home-as-up
* indicator using {@link #setHomeAsUpIndicator(int)} to indicate more specific
* functionality such as a sliding drawer, you should also set this to accurately
* describe the action.</p>
*
* <p>Setting this to <code>null</code> will use the system default description.</p>
*
* @param description New description for the Home action when enabled
* @see #setHomeAsUpIndicator(int)
* @see #setHomeAsUpIndicator(android.graphics.drawable.Drawable)
*/
public void setHomeActionContentDescription(CharSequence description) { }
/**
* Set an alternate description for the Home/Up action, when enabled.
*
* <p>This description is commonly used for accessibility/screen readers when
* the Home action is enabled. (See {@link #setDisplayHomeAsUpEnabled(boolean)}.)
* Examples of this are, "Navigate Home" or "Navigate Up" depending on the
* {@link #DISPLAY_HOME_AS_UP} display option. If you have changed the home-as-up
* indicator using {@link #setHomeAsUpIndicator(int)} to indicate more specific
* functionality such as a sliding drawer, you should also set this to accurately
* describe the action.</p>
*
* <p>Setting this to <code>0</code> will use the system default description.</p>
*
* @param resId Resource ID of a string to use as the new description
* for the Home action when enabled
* @see #setHomeAsUpIndicator(int)
* @see #setHomeAsUpIndicator(android.graphics.drawable.Drawable)
*/
public void setHomeActionContentDescription(@StringRes int resId) { }
/**
* Enable hiding the action bar on content scroll.
*
* <p>If enabled, the action bar will scroll out of sight along with a
* {@link View#setNestedScrollingEnabled(boolean) nested scrolling child} view's content.
* The action bar must be in {@link Window#FEATURE_ACTION_BAR_OVERLAY overlay mode}
* to enable hiding on content scroll.</p>
*
* <p>When partially scrolled off screen the action bar is considered
* {@link #hide() hidden}. A call to {@link #show() show} will cause it to return to full view.
* </p>
* @param hideOnContentScroll true to enable hiding on content scroll.
*/
public void setHideOnContentScrollEnabled(boolean hideOnContentScroll) {
if (hideOnContentScroll) {
throw new UnsupportedOperationException("Hide on content scroll is not supported in " +
"this action bar configuration.");
}
}
/**
* Return whether the action bar is configured to scroll out of sight along with
* a {@link View#setNestedScrollingEnabled(boolean) nested scrolling child}.
*
* @return true if hide-on-content-scroll is enabled
* @see #setHideOnContentScrollEnabled(boolean)
*/
public boolean isHideOnContentScrollEnabled() {
return false;
}
/**
* Return the current vertical offset of the action bar.
*
* <p>The action bar's current hide offset is the distance that the action bar is currently
* scrolled offscreen in pixels. The valid range is 0 (fully visible) to the action bar's
* current measured {@link #getHeight() height} (fully invisible).</p>
*
* @return The action bar's offset toward its fully hidden state in pixels
*/
public int getHideOffset() {
return 0;
}
/**
* Set the current hide offset of the action bar.
*
* <p>The action bar's current hide offset is the distance that the action bar is currently
* scrolled offscreen in pixels. The valid range is 0 (fully visible) to the action bar's
* current measured {@link #getHeight() height} (fully invisible).</p>
*
* @param offset The action bar's offset toward its fully hidden state in pixels.
*/
public void setHideOffset(int offset) {
if (offset != 0) {
throw new UnsupportedOperationException("Setting an explicit action bar hide offset " +
"is not supported in this action bar configuration.");
}
}
/**
* Set the Z-axis elevation of the action bar in pixels.
*
* <p>The action bar's elevation is the distance it is placed from its parent surface. Higher
* values are closer to the user.</p>
*
* @param elevation Elevation value in pixels
*/
public void setElevation(float elevation) {
if (elevation != 0) {
throw new UnsupportedOperationException("Setting a non-zero elevation is " +
"not supported in this action bar configuration.");
}
}
/**
* Get the Z-axis elevation of the action bar in pixels.
*
* <p>The action bar's elevation is the distance it is placed from its parent surface. Higher
* values are closer to the user.</p>
*
* @return Elevation value in pixels
*/
public float getElevation() {
return 0;
}
/** @hide */
public void setDefaultDisplayHomeAsUpEnabled(boolean enabled) {
}
/** @hide */
@UnsupportedAppUsage
public void setShowHideAnimationEnabled(boolean enabled) {
}
/** @hide */
public void onConfigurationChanged(Configuration config) {
}
/** @hide */
public void dispatchMenuVisibilityChanged(boolean visible) {
}
/** @hide */
public ActionMode startActionMode(ActionMode.Callback callback) {
return null;
}
/** @hide */
public boolean openOptionsMenu() {
return false;
}
/** @hide */
public boolean closeOptionsMenu() {
return false;
}
/** @hide */
public boolean invalidateOptionsMenu() {
return false;
}
/** @hide */
public boolean onMenuKeyEvent(KeyEvent event) {
return false;
}
/** @hide */
public boolean onKeyShortcut(int keyCode, KeyEvent event) {
return false;
}
/** @hide */
@UnsupportedAppUsage
public boolean collapseActionView() {
return false;
}
/** @hide */
public void setWindowTitle(CharSequence title) {
}
/** @hide */
public void onDestroy() {
}
/**
* Listener interface for ActionBar navigation events.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public interface OnNavigationListener {
/**
* This method is called whenever a navigation item in your action bar
* is selected.
*
* @param itemPosition Position of the item clicked.
* @param itemId ID of the item clicked.
* @return True if the event was handled, false otherwise.
*/
public boolean onNavigationItemSelected(int itemPosition, long itemId);
}
/**
* Listener for receiving events when action bar menus are shown or hidden.
*/
public interface OnMenuVisibilityListener {
/**
* Called when an action bar menu is shown or hidden. Applications may want to use
* this to tune auto-hiding behavior for the action bar or pause/resume video playback,
* gameplay, or other activity within the main content area.
*
* @param isVisible True if an action bar menu is now visible, false if no action bar
* menus are visible.
*/
public void onMenuVisibilityChanged(boolean isVisible);
}
/**
* A tab in the action bar.
*
* <p>Tabs manage the hiding and showing of {@link Fragment}s.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public static abstract class Tab {
/**
* An invalid position for a tab.
*
* @see #getPosition()
*/
public static final int INVALID_POSITION = -1;
/**
* Return the current position of this tab in the action bar.
*
* @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in
* the action bar.
*/
public abstract int getPosition();
/**
* Return the icon associated with this tab.
*
* @return The tab's icon
*/
public abstract Drawable getIcon();
/**
* Return the text of this tab.
*
* @return The tab's text
*/
public abstract CharSequence getText();
/**
* Set the icon displayed on this tab.
*
* @param icon The drawable to use as an icon
* @return The current instance for call chaining
*/
public abstract Tab setIcon(Drawable icon);
/**
* Set the icon displayed on this tab.
*
* @param resId Resource ID referring to the drawable to use as an icon
* @return The current instance for call chaining
*/
public abstract Tab setIcon(@DrawableRes int resId);
/**
* Set the text displayed on this tab. Text may be truncated if there is not
* room to display the entire string.
*
* @param text The text to display
* @return The current instance for call chaining
*/
public abstract Tab setText(CharSequence text);
/**
* Set the text displayed on this tab. Text may be truncated if there is not
* room to display the entire string.
*
* @param resId A resource ID referring to the text that should be displayed
* @return The current instance for call chaining
*/
public abstract Tab setText(@StringRes int resId);
/**
* Set a custom view to be used for this tab. This overrides values set by
* {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
*
* @param view Custom view to be used as a tab.
* @return The current instance for call chaining
*/
public abstract Tab setCustomView(View view);
/**
* Set a custom view to be used for this tab. This overrides values set by
* {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
*
* @param layoutResId A layout resource to inflate and use as a custom tab view
* @return The current instance for call chaining
*/
public abstract Tab setCustomView(@LayoutRes int layoutResId);
/**
* Retrieve a previously set custom view for this tab.
*
* @return The custom view set by {@link #setCustomView(View)}.
*/
public abstract View getCustomView();
/**
* Give this Tab an arbitrary object to hold for later use.
*
* @param obj Object to store
* @return The current instance for call chaining
*/
public abstract Tab setTag(Object obj);
/**
* @return This Tab's tag object.
*/
public abstract Object getTag();
/**
* Set the {@link TabListener} that will handle switching to and from this tab.
* All tabs must have a TabListener set before being added to the ActionBar.
*
* @param listener Listener to handle tab selection events
* @return The current instance for call chaining
*/
public abstract Tab setTabListener(TabListener listener);
/**
* Select this tab. Only valid if the tab has been added to the action bar.
*/
public abstract void select();
/**
* Set a description of this tab's content for use in accessibility support.
* If no content description is provided the title will be used.
*
* @param resId A resource ID referring to the description text
* @return The current instance for call chaining
* @see #setContentDescription(CharSequence)
* @see #getContentDescription()
*/
public abstract Tab setContentDescription(@StringRes int resId);
/**
* Set a description of this tab's content for use in accessibility support.
* If no content description is provided the title will be used.
*
* @param contentDesc Description of this tab's content
* @return The current instance for call chaining
* @see #setContentDescription(int)
* @see #getContentDescription()
*/
public abstract Tab setContentDescription(CharSequence contentDesc);
/**
* Gets a brief description of this tab's content for use in accessibility support.
*
* @return Description of this tab's content
* @see #setContentDescription(CharSequence)
* @see #setContentDescription(int)
*/
public abstract CharSequence getContentDescription();
}
/**
* Callback interface invoked when a tab is focused, unfocused, added, or removed.
*
* @deprecated Action bar navigation modes are deprecated and not supported by inline
* toolbar action bars. Consider using other
* <a href="http://developer.android.com/design/patterns/navigation.html">common
* navigation patterns</a> instead.
*/
@Deprecated
public interface TabListener {
/**
* Called when a tab enters the selected state.
*
* @param tab The tab that was selected
* @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
* during a tab switch. The previous tab's unselect and this tab's select will be
* executed in a single transaction. This FragmentTransaction does not support
* being added to the back stack.
*/
public void onTabSelected(Tab tab, FragmentTransaction ft);
/**
* Called when a tab exits the selected state.
*
* @param tab The tab that was unselected
* @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
* during a tab switch. This tab's unselect and the newly selected tab's select
* will be executed in a single transaction. This FragmentTransaction does not
* support being added to the back stack.
*/
public void onTabUnselected(Tab tab, FragmentTransaction ft);
/**
* Called when a tab that is already selected is chosen again by the user.
* Some applications may use this action to return to the top level of a category.
*
* @param tab The tab that was reselected.
* @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
* once this method returns. This FragmentTransaction does not support
* being added to the back stack.
*/
public void onTabReselected(Tab tab, FragmentTransaction ft);
}
/**
* Per-child layout information associated with action bar custom views.
*
* @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity
*/
public static class LayoutParams extends ViewGroup.MarginLayoutParams {
/**
* Gravity for the view associated with these LayoutParams.
*
* @see android.view.Gravity
*/
@ViewDebug.ExportedProperty(category = "layout", mapping = {
@ViewDebug.IntToString(from = -1, to = "NONE"),
@ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"),
@ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"),
@ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"),
@ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"),
@ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"),
@ViewDebug.IntToString(from = Gravity.START, to = "START"),
@ViewDebug.IntToString(from = Gravity.END, to = "END"),
@ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"),
@ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"),
@ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"),
@ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"),
@ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"),
@ViewDebug.IntToString(from = Gravity.FILL, to = "FILL")
})
@InspectableProperty(
name = "layout_gravity",
valueType = InspectableProperty.ValueType.GRAVITY)
public int gravity = Gravity.NO_GRAVITY;
public LayoutParams(@NonNull Context c, AttributeSet attrs) {
super(c, attrs);
TypedArray a = c.obtainStyledAttributes(attrs,
com.android.internal.R.styleable.ActionBar_LayoutParams);
gravity = a.getInt(
com.android.internal.R.styleable.ActionBar_LayoutParams_layout_gravity,
Gravity.NO_GRAVITY);
a.recycle();
}
public LayoutParams(int width, int height) {
super(width, height);
this.gravity = Gravity.CENTER_VERTICAL | Gravity.START;
}
public LayoutParams(int width, int height, int gravity) {
super(width, height);
this.gravity = gravity;
}
public LayoutParams(int gravity) {
this(WRAP_CONTENT, MATCH_PARENT, gravity);
}
public LayoutParams(LayoutParams source) {
super(source);
this.gravity = source.gravity;
}
public LayoutParams(ViewGroup.LayoutParams source) {
super(source);
}
/*
* Note for framework developers:
*
* You might notice that ActionBar.LayoutParams is missing a constructor overload
* for MarginLayoutParams. While it may seem like a good idea to add one, at this
* point it's dangerous for source compatibility. Upon building against a new
* version of the SDK an app can end up statically linking to the new MarginLayoutParams
* overload, causing a crash when running on older platform versions with no other changes.
*/
/** @hide */
@Override
protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) {
super.encodeProperties(encoder);
encoder.addProperty("gravity", gravity);
}
}
}
|