我刚刚升级到API 26并支持库26.0.2.但我发现RecyclerView滚动后我的项目无法点击.如果你等一下,它会起作用.但是如果你立即点击该项目,它就不会.即使RecyclerView根本没有滚动(例如已滚动到顶部).
当我降级为支持库25.4.0时,一切都会好起来的.关键的一点是,我RecyclerView是在CoordinatorLayout和具有SCROLL_FLAG_SCROLL标志上我Toolbar的AppBarLayout.如果我不使用此标志,则此问题将消失.所以我认为这是支持库26的隐藏行为变化.
我试图添加focusable="false"到CoordinatorLayout但仍然没有运气.
有没有办法禁用这种行为?因为点击两次触发点击事件真的很烦人.
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinateLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/fragmentAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp"
android:background="@null">
<include
android:id="@+id/dynamicActionBarHolder"
layout="@layout/dynamic_action_bar"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/pullToRefreshMailRecycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/mailRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
编辑
我认为这个问题是scrollState的RecyclerView.当它停止滚动时,它不会SCROLL_STATE_IDLE立即更改为.查看源代码RecyclerView,我发现有一个ViewFlinger控制滚动状态.当我向下滚动到顶部时,它不会setScrollState(SCROLL_STATE_IDLE)立即调用,而是等待一段时间来触发此方法.我越快,我需要等待的时间越多.就像RecyclerView仍然在后台滚动一样.因为在触摸顶部时停止滚动scroller.isFinished()后不会返回true RecyclerView.也许这是一个错误RecyclerView的时间CoordinatorLayout.
android android-support-library android-recyclerview android-coordinatorlayout
我正在使用firebase-ads:9.2.0,API级别为24.
通过在我的build.gradle中添加compile(名称:'unity-ads',ext:'aar')来导入unity-ads aar模块.
如果我选择直接使用UnityAds API,一切都会好起来的.
但是,当我尝试将统一广告与AdMob集成时,如下所示:
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance( this );
mRewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {
@Override
public void onRewardedVideoAdLoaded() {
logger.debug("onRewardedVideoAdLoaded");
}
@Override
public void onRewardedVideoAdOpened() {
logger.debug("onRewardedVideoAdOpened");
}
@Override
public void onRewardedVideoStarted() {
logger.debug("onRewardedVideoStarted");
}
@Override
public void onRewardedVideoAdClosed() {
logger.debug("onRewardedVideoAdClosed");
}
@Override
public void onRewarded(RewardItem rewardItem) {
logger.debug("onRewarded");
}
@Override
public void onRewardedVideoAdLeftApplication() {
logger.debug("onRewardedVideoAdLeftApplication");
}
@Override
public void onRewardedVideoAdFailedToLoad(int i) {
Toast.makeText(
getApplicationContext(),
"onRewardedVideoAdFailedToLoad",
Toast.LENGTH_SHORT ).show();
}
});
AdRequest adRewardRequest = new AdRequest.Builder()
.addTestDevice("E921B48960E16DA3ABD13C4AFB7052A4")
.build();
mRewardedVideoAd.loadAd(
getResources().getString(R.string.reward_ad_unit_id),
adRewardRequest …Run Code Online (Sandbox Code Playgroud) I know there are a bunch of similar questions on stackoverflow. But none of these solve my problem.
It's not about theme settings nor resource not found. And I didn't load large images in this layout(all of the backgrounds are from drawable xml). All the attributes have accurate values, including namespace declaration. It just throws this exception randomly. Looks like an android bug.
It happens on Nexus 5X, Nexus 6P, HTC_A9u, ASUS_Z012, etc. I'm using API 25, support library 25.0.1, …
我使用片段替换FrameLayout fragmentTransaction.replace().
布局:
<FrameLayout
android:id="@+id/articlesAppender"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
替换Activity的onCreate:
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
articlesFragment = (ArticlesFragment) fragmentManager.findFragmentByTag(ARTICLES_FRAGMENT_TAG);
if (articlesFragment == null) {
articlesFragment = new ArticlesFragment();
}
fragmentTransaction.replace(R.id.articlesAppender, articlesFragment, ARTICLES_FRAGMENT_TAG);
fragmentTransaction.commit();
Run Code Online (Sandbox Code Playgroud)
ArticleFragment的onCreate:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.articles_fragment, container, false);
view.setVisibility(View.GONE);
return view;
}
Run Code Online (Sandbox Code Playgroud)
但是view.setVisibility(View.GONE);不支持库25.1.0.因此片段仍将显示在屏幕上.如果我设置了articlesAppenderto 的可见性GONE.所以看起来应该是这样的:
<FrameLayout
android:id="@+id/articlesAppender"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
然后片段在屏幕上将不可见,但是当我稍后尝试呼叫时view.setVisibility(View.VISIBLE);,它仍然不起作用.片段仍然不可见.
这意味着view返回的inflater.inflate(R.layout.articles_fragment, container, false);不是片段的真实视图.但它在支持库25.0.1上完美运行. …
我把Realm.init(this)放在我的Application类的onCreate中.
但是当我在我的Activity的onCreate中调用Realm.getDefaultInstance()时,它会抛出一个异常.
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2511)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1360)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5480)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalStateException: Call `Realm.init(Context)` before calling this method.
at io.realm.Realm.getDefaultInstance(Realm.java:208)
at com.kimi.fastdb.PrefActivity.getRealmHelper(PrefActivity.java:1724)
at com.kimi.fastdb.PrefActivity.onCreate(PrefActivity.java:270)
at com.kimi.fastdb.LauncherActivity.onCreate(LauncherActivity.java:464)
at android.app.Activity.performCreate(Activity.java:6308)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
Run Code Online (Sandbox Code Playgroud)
应用程序启动后为什么没有初始化领域实例?以及如何解决它?
应用:
public class App extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
Realm.init(this);
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
.schemaVersion( REALM_DATABASE_VERSION ) // Must be bumped when the schema changes
.migration( migration ) // Migration to …Run Code Online (Sandbox Code Playgroud) 从 API 24 开始,RecyclerView将自动滚动到用户单击该项目部分显示的项目。如何禁用此功能?
下面的代码在support-library 25.0.1.
@Override
public boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate) {
Object tag = child.getTag();
if( tag != null && tag.toString().equalsIgnoreCase("preventAutoScroll") ){
return false;
}
return super.requestChildRectangleOnScreen(child, rect, immediate);
}
Run Code Online (Sandbox Code Playgroud)
它必须是可聚焦和可点击的,因为它是 aTextView并且文本需要是可选择的。