我正在使用最新版本的 ViewPager2 'androidx.viewpager2:viewpager2:1.0.0-beta04'
我有 10 页,每一页都是 Fragment。
如果我设置,viewpager2.offscreenPageLimit = 1
我必须滚动到第 5 页以使第一页销毁。
发生了什么???,当我滚动到第 3 页时,第一页应该被破坏了吧??
然后我尝试另一种方式使它正确
(viewpager2.getChildAt(0) as RecyclerView).layoutManager?.isItemPrefetchEnabled = false
(viewpager2.getChildAt(0) as RecyclerView).setItemViewCacheSize(1)
Run Code Online (Sandbox Code Playgroud)
这样,当我滚动到第 3 页时,第一页将被破坏,它现在正在工作
任何人都可以向我解释这两个属性之间的区别吗?
非常感谢
目前,我正在使用此正则表达式来检测日语主题标签和英语主题标签。
\B([#?][·??_0-9?-?a-zA-Z?-??-??-??-??-?]{1,24})(?=\W|$)
规则是:
Hashtag must be started with # character.
Hashtag will be detected by space character and other special characters (!,@,&,*,%,$).
Example 1: Hello#guys. This is a #test. -> Valid hashtag: #test.
Example 2: Hello#guys. This is a #test!#message. -> Valid hashtag: #test and #message
Example 3: Hello#guys. This is a #test #message. -> Valid hashtag: #test and #message
Example 4: Hello#guys. This is a #test#message. -> Valid hashtag: #test
Example 5: #asdasdasdasdasdasdasdasdasd -> Valid hashtag: none
Example 6: …
Run Code Online (Sandbox Code Playgroud) 我想在RecyclerView的项目中隐藏View.我if/else
在BindViewHolder中有声明,如下所示:
if (position == list.size() - 1)
{
holder.divider.setVisibility(View.Gone)
}
Run Code Online (Sandbox Code Playgroud)
它最初工作,我的视图消失但当我向后滚动时,一些视图也消失了,我不知道解决这个问题,我试过holder.getAdapterposition
但仍然发生了同样的事情.如果有人可以帮助我,我将非常感激.
android android-studio android-viewholder android-recyclerview
每当我重建项目时,我都会不断收到此错误
****/ data binding error ****msg:Multiple binding data tags in
C:\Users\Tai\AndroidStudioProjects\Rxjava2Practice2 -
Copy\app\src\main\res\layout\item_movie.xml. Expecting a maximum of one.
file:C:\Users\Tai\AndroidStudioProjects\Rxjava2Practice2 -
Copy\app\src\main\res\layout\item_movie.xml
****\ data binding error ****
Run Code Online (Sandbox Code Playgroud)
有时ItemMovieBinding
也不会像往常一样自动生成,但是在我重新启动android studio之后,它又可以正常工作了。
这是我的item_movie.xml
,我确实尝试清理并重建或重新启动android studio,但根本没有任何效果
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bind="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="result"
type="com.example.tai.rxjava2practice2.Model.Result"></variable>
</data>
<data>
<variable
name="image"
type="com.example.tai.rxjava2practice2.Model.Image"></variable>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_MovieName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_Avatar"
android:layout_weight="1"
android:text="@{result.title}"
android:textSize="16dp" />
<TextView
android:id="@+id/tv_ReleaseDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_Avatar"
android:layout_weight="1"
android:gravity="right"
android:text="@{result.releaseDate}"
android:textSize="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent" …
Run Code Online (Sandbox Code Playgroud)