小编M M*_*han的帖子

RecyclerView错误的位置设置onBindViewHolder

首先,我的RecyclerView项目没问题,但在滚动时,项目显示在错误的位置,例如:项目6显示在位置67.虽然onClick listener和getAdapterPosition()工作正常并显示正确的项目.为什么?

import android.content.Context;
import android.graphics.Typeface;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.neganet.darotabii.R;
import com.neganet.darotabii.beans.headers_Bean;
import java.util.List;
public class FSecAdapter2 extends RecyclerView.Adapter<FSecAdapter2.mViewHolder> {

    private static List<headers_Bean> items_t;
    private static int secNo;
    private Typeface font;
    private boolean showSoreName;
    private static Context mContext;
    private static String ?olorString;

  private static String fSubjectText="";
    private static Static_Datas static_datas;
    private static QDataGetter dataGetter;

public FSecAdapter2(List<headers_Bean> t_items, Context cnt, int secNo) {
            setHasStableIds(true);

            this.mContext=cnt;
            this.items_t = t_items;
            this.static_datas=new Static_Datas(mContext);
            this.secNo=secNo;
         }

        public …
Run Code Online (Sandbox Code Playgroud)

android recycler-adapter android-recyclerview

13
推荐指数
3
解决办法
6511
查看次数

如何等待 async void 方法完成其任务?

在 Java 中,我们有 Awaitility 类,在其中我们可以等待布尔返回方法返回 true 或 false。

对于 void 方法我们如何做到这一点?

java asynchronous async-await

7
推荐指数
1
解决办法
3784
查看次数

在没有它的情况下进行别名时,在SQL中使用"AS"关键字有什么意义?

  1. 从员工中选择薪水*12作为"年薪";
  2. 从员工中选择薪水*12"年薪";

两个查询都会给出相同的结果,"AS"会有什么不同吗?如果是的话,它是什么?如果没有,那么使用它有什么意义呢?

mysql sql sql-server oracle

3
推荐指数
2
解决办法
570
查看次数

如何在现有数据库中生成新的非空列的默认值

我有一个现有的数据库。需要添加具有默认值的新非空列。使用 ValueGenerator 接口在 hibernate 4.3 中可以完成同样的操作。但是我的项目有 hibernate 3.6,它不提供此功能。有什么方法可以使用冬眠。

java database hibernate

0
推荐指数
1
解决办法
3412
查看次数

从文本文件中读取一行

我试图从文本文件中读取一行,但程序仍然返回一个错误,指出无法找到该文件的名称.关于如何解决问题的任何想法.

源代码:

import java.io.FileReader;
import java.io.BufferedReader;

public class Cipher {

    public String file_name;

    public Cipher(){
        file_name = "/Users/SubrataMohanty/IdeaProjects/CaesarCipher/src/cipher_text.txt";

    }

    public static void main(String[] args) {

        BufferedReader br = null;
        FileReader fr = null;

        Cipher cipher_1 = new Cipher();


        fr = new FileReader(cipher_1.file_name);
        br = new BufferedReader(fr);

        String current_line;

        while ((current_line = br.readLine()) != null){
            System.out.println(current_line);
        }

        }

    }
Run Code Online (Sandbox Code Playgroud)

经过调试,这就是我得到的,

Error:(25, 14) java: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
Error:(30, 43) java: unreported exception java.io.IOException; must …
Run Code Online (Sandbox Code Playgroud)

java file

-1
推荐指数
1
解决办法
117
查看次数