小编Moh*_* AH的帖子

在android中启用RecyclerView快速滚动设置固定高度滚动拇指

我使用以下属性实现了 RecyclerView 快速滚动:

<android.support.v7.widget.RecyclerView
...
 app:fastScrollEnabled="true"
 app:fastScrollHorizontalThumbDrawable="@drawable/fast_scroll_thumb"
 app:fastScrollHorizontalTrackDrawable="@drawable/fast_scroll_track"
 app:fastScrollVerticalThumbDrawable="@drawable/fast_scroll_thumb"
 app:fastScrollVerticalTrackDrawable="@drawable/fast_scroll_track"/>
Run Code Online (Sandbox Code Playgroud)

fast_scroll_thumb.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true">
        <shape android:shape="rectangle">
            <solid android:color="@color/lightBlue" />
        </shape>
    </item>
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/lightBlue" />
        </shape>
    </item>
</selector>
Run Code Online (Sandbox Code Playgroud)

fast_scroll_track.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@color/gray" />
</shape>
Run Code Online (Sandbox Code Playgroud)

但是,快速滚动拇指大小取决于数据数量。随着 RecyclerView 数据的增加,拇指大小减小。有没有办法将拇指大小固定在固定高度?

android fastscroll android-recyclerview

7
推荐指数
0
解决办法
1120
查看次数

Room - 删除表并重置其主键

我想在添加新表之前删除表中的所有整体并将 PrimaryKey 重置回 1。

这是我的实体

@PrimaryKey(autoGenerate = true)
private int id;
private int weatherId;
private String highTemp;
private String lowTemp;
Run Code Online (Sandbox Code Playgroud)

所以我用了

if(weatherEntries != null && weatherEntries.size() != 0){
        Log.d(TAG, "WeatherEntry List is not empty");
            mDb.clearAllTables();


            for(int i = 0; i < weatherEntries.size(); i++) {
                mDb.weatherDao().insertWeather(weatherEntries.get(i));
                Log.d(TAG, "Inserting Weather Data into the Database");
            }
        }
Run Code Online (Sandbox Code Playgroud)

当添加新条目时,它们的主键不是从 1 开始。所以,我厌倦了查询

@Query("ALTER TABLE SequenceAction AUTO_INCREMENT = 0")
void clearPrimaryKey();
Run Code Online (Sandbox Code Playgroud)

我收到错误

“错误:输入‘SequenceAction AUTO_INCRMENT’处没有变量替代”

我试图在谷歌上查找如何解决这个问题,甚至查看了 Room 的 Android 文档以了解如何重置主键,但没有找到任何内容。

任何帮助将不胜感激。

sqlite android android-room

5
推荐指数
1
解决办法
2049
查看次数