小编Pla*_*iam的帖子

向下滚动时,RecyclerView项目之间形成较大的间隙

我正在制作ToDo列表应用程序,并且在测试时,出于某种原因,每当我尝试向下滚动时,项目之间会形成巨大的差距.每当我拖放项目时总会发生这种情况,但我没有看到我的ItemTouchHelper适配器和回调类有任何错误.如果你可以帮助我,那将是非常棒的.

之前: 之前

后: 后

RecyclerAdapter.java

public class RecyclerAdapter extends                                                                                                                                 

RecyclerView.Adapter<RecyclerAdapter.RecyclerVH> implements ItemTouchHelperAdapter{
private LayoutInflater layoutInflater;
ArrayList<Info> data;
Context context;

public RecyclerAdapter(Context context) {
    layoutInflater = LayoutInflater.from(context);
    this.context = context;
}

public void setData(ArrayList<Info> data) {
    this.data = data;
    notifyDataSetChanged();
}

@Override
public RecyclerVH onCreateViewHolder(ViewGroup viewGroup, int position) {
    View view = layoutInflater.inflate(R.layout.custom_row, viewGroup, false);
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d("R.A onClick Owen", "onClick method triggered");
        }
    });
    RecyclerVH recyclerVH = new RecyclerVH(view);
    return recyclerVH;
}

@Override
public …
Run Code Online (Sandbox Code Playgroud)

android android-scrollview android-recyclerview

35
推荐指数
3
解决办法
3万
查看次数

FloatingActionButton类无法实例化

在看了Material Design中的新方法之后,我尝试在应用程序中实现一个浮动操作按钮.但是,我在预览中遇到此错误(预览Android版本21):

The following classes could not be instantiated:
- android.support.design.widget.FloatingActionButton
(First paragraph of error)
java.lang.NullPointerException
at android.support.v4.graphics.drawable.DrawableCompatLollipop.setTintList(DrawableCompatLollipop.java:56)
at android.support.v4.graphics.drawable.DrawableCompat$LollipopDrawableImpl.setTintList(DrawableCompat.java:145)
at android.support.v4.graphics.drawable.DrawableCompat.setTintList(DrawableCompat.java:270)
etc...
Run Code Online (Sandbox Code Playgroud)

任何人都有任何想法?这是我的build.gradle:

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
classpath 'com.android.tools.build:gradle:1.2.3'


defaultConfig {
    applicationId "owensetiawan.tutorials.fab"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
}
Run Code Online (Sandbox Code Playgroud)

如果有人可以帮助我解决我的问题,那绝对是太棒了.

android android-layout

12
推荐指数
2
解决办法
2万
查看次数

使用动画使ItemDecoration移动

我在我的RecyclerView中实现了ItemDecoration以及在加载RV时播放的动画.但是,我注意到装饰在动画完成之前已经出现在界限处,我想让装饰同时移动到动画中.我该怎么做?

到目前为止,我一直在进入动画:

@Override
    public void onBindViewHolder(final RecyclerVH recyclerVH, final int position) {
    currentNote = data.get(position);
    final String currentTitle = currentNote.getTitle();
    final String currentContent = currentNote.getContent();
    final int currentPosition = currentNote.getPosition();
    String currentAlarmDate = currentNote.getAlarm();

    Log.d("RecyclerView", "onBindVH called: " + currentTitle);
    Log.d("RecyclerView", "Position at: " + currentPosition + " and Adapter Position at: " + recyclerVH.getAdapterPosition());

    // final Info currentObject = data.get(position);
    // Current Info object retrieved for current RecyclerView item - USED FOR DELETE
    recyclerVH.listTitle.setText(currentTitle);
    recyclerVH.listContent.setText(currentContent);
    Log.d("RecyclerAdapter", "currentAlarmDate is: '" …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

8
推荐指数
1
解决办法
2062
查看次数

在 SQLite 中保存重新排序的 RecyclerView

所以我试图Drag-and-Drop在我的待办事项列表应用程序中实现,但是我在保存移动后的行顺序时遇到了麻烦 - 即我移动了项目,退出了应用程序,然后它恢复到原来的位置。我想到了一个解决办法。

我的解决方案:

在我的表中创建一列:specification_position。每次移动一行时,该onItemMove()方法都会返回 afromPositiontoPosition。将行的位置移动到toPosition,然后增加/更新那里和上面的所有值。每次读取表格时,它都会检查头寸并根据它对它们进行排序。

我的问题:

我的解决方案是否正确?有没有更好,更简单的方法来代替这样做?非常感谢!

sqlite android android-recyclerview

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

使用KIF以编程方式将tap事件发送到iOS背景中的坐标

我们的想法是创建一个应用程序,可以在iOS中的另一个应用程序的后台连续发送"在坐标(x,y)"事件中点击屏幕.想想'Cookie Clicker'作弊.我目前正在他的应用程序中帮助我的朋友,我的工作是尝试尽可能地将其排除在外.我有一种轻微的感觉,即尽可能多地敲击他的一个按钮会使他的应用程序出错,这就是为什么我在这里.

该方法使用KIF以及iOS中的后台执行来实现此目的.

  1. 在其中一个类中,文件KIFUITestActor.m具有以下代码:

    - (void)tapScreenAtPoint:(CGPoint)screenPoint
    {
    
    [self runBlock:^KIFTestStepResult(NSError **error) {
    
    // Try all the windows until we get one back that actually has something in it at the given point
    UIView *view = nil;
    for (UIWindow *window in [[[UIApplication sharedApplication] windowsWithKeyWindow] reverseObjectEnumerator]) {
        CGPoint windowPoint = [window convertPoint:screenPoint fromView:nil];
        view = [window hitTest:windowPoint withEvent:nil];
    
        // If we hit the window itself, then skip it.
        if (view != window && view != nil) {
            break;
        }
    }
    
    KIFTestWaitCondition(view, error, @"No …
    Run Code Online (Sandbox Code Playgroud)

iphone background objective-c ios kif

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