Tag: appcompat v7 r22.1

您需要使用Theme.AppCompat主题(或后代)与此活动。 更改为Theme.AppCompat会导致其他错误

我在我的应用程序中使用appcompat v22.1.0并使用工具栏。 一切都很好,当我使用Theme.AppCompat.Light.NoActionBar 。 当我开始实现AlertDialog ,它会产生像这样的错误: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:113) at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146) at android.support.v7.app.AppCompatDialog.<init>(AppCompatDialog.java:47) at android.support.v7.app.AlertDialog.<init>(AlertDialog.java:92) at android.support.v7.app.AlertDialog$Builder.create(AlertDialog.java:882) at com.ramabmtr.map.findingmoo.MainActivity.onOptionsItemSelected(MainActivity.java:216) at android.app.Activity.onMenuItemSelected(Activity.java:2572) at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:353) at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:144) at android.support.v7.internal.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:99) at android.support.v7.internal.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:99) at android.support.v7.internal.app.ToolbarActionBar$2.onMenuItemClick(ToolbarActionBar.java:74) at android.support.v7.widget.Toolbar$1.onMenuItemClick(Toolbar.java:164) at android.support.v7.widget.ActionMenuView$MenuBuilderCallback.onMenuItemSelected(ActionMenuView.java:740) at android.support.v7.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:802) at android.support.v7.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:153) at android.support.v7.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:949) at android.support.v7.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:939) […]

如何在Android上实现NestedScrolling?

使用support-v4库22.1.0 android支持嵌套滚动(pre android 5.0)。 不幸的是,这个function没有真正的logging。 有两个接口( NestedScrollingParent和NestedScrollingChild )以及两个辅助委托类( NestedScrollingChildHelper和NestedScrollingParentHelper )。 有没有人在Android上使用NestedScrolling? 我试图设置一个小例子,在那里我使用NestedScrolling实现了NestedScrollingParent和NestedScrollingChild 。 我的布局看起来像这样: <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/parent" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <View android:id="@+id/header" android:layout_width="match_parent" android:layout_height="100dp" android:background="#AF1233"/> <android.support.v4.widget.NestedScrollView android:id="@+id/child" android:layout_width="match_parent" android:layout_height="wrap_content" > <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#12AF33" android:text="@string/long_text"/> </FrameLayout> </android.support.v4.widget.NestedScrollView> </LinearLayout> </android.support.v4.widget.NestedScrollView> 我想要在NestedScrollView (id = parent)中显示一个header view和另一个NestedScrollView (id = […]

创buildActionMode时不会调用onPrepareActionMode

我刚刚完成了一个我的应用程序调整到新的v22.1.1支持&appcompat库,看到这里和这里的更多细节。 当我做了一些testing的时候,我正在使用ActionModes 。 使用startSupportActionMode()调用启动ActionMode时 – 使用现在不推荐使用的ActionBarActivity基类或新的AppCompatActivity基类时onPrepareActionMode() – onPrepareActionMode()没有被调用。 在以前的版本中,包括v21.0.3和v22.0.0,当ActionMode最初使用startSupportActionMode()创build时,会自动调用startSupportActionMode() 。 我在2.2,4.0.2和5.0版本的设备上testing过,所以它不是版本依赖的。 有没有人知道,如果这是意向的行为,这是在v22.1.1引入,或一个错误? 我发现这个问题 ,但是这里没有太多的反馈 2015年5月11日编辑: 正如Android问题追踪器159527中提到的,这个问题不仅影响到appcompat的v22.1.x和支持库,还影响到了5.1 Android的实现。 目前有两种可能的临时解决scheme, @Override public ActionMode startSupportActionMode(final ActionMode.Callback callback) { // Fix for bug https://code.google.com/p/android/issues/detail?id=159527 final ActionMode mode = super.startSupportActionMode(callback); if (mode != null) { mode.invalidate(); } return mode; } 和一个“快速和肮脏的”(当你实例化你的ActionMode): final ActionMode actionMode = startSupportActionMode(new MyActionMode()); if(actionMode != null) […]