在EditText中输入输入后,如果向上或向下滚动非常快,则输入值会在RecyclerView中的另一个EditText中交换其位置.
在滚动之前,数据位于第一个EditText中.
在向上和向下滚动之后,第一个EditText的值将其位置更改为第4个,并且交换是随机的.是否有任何工作来稳定数据.
这是模型类:
public class Product {
public int pId;
public String pName;
public double unit_price;
public double discount;
}
Run Code Online (Sandbox Code Playgroud)
这是适配器类:
public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ProductListHolder> {
Context context;
List<Product> productList;
public ProductAdapter(Context c, List<Product> lp){
this.context = c;
this.productList = lp;
}
public class ProductListHolder extends RecyclerView.ViewHolder{
TextView tvName;
TextView tvPrice;
TextView tvDiscount;
TextView tvTotal;
EditText etQuantity;
public ProductListHolder(View itemView) {
super(itemView);
tvName = (TextView) itemView.findViewById(R.id.tvName);
tvPrice = (TextView) itemView.findViewById(R.id.tvPrice);
tvDiscount = (TextView) itemView.findViewById(R.id.tvDiscount);
tvTotal = (TextView) …Run Code Online (Sandbox Code Playgroud) android android-edittext android-viewholder android-recyclerview
我有一张简单的桌子.我正在尝试将默认值放入TEXT列.这是表查询:
"CREATE TABLE book(_id INTEGER PRIMARY KEY AUTOINCREMENT, book_id TEXT NOT NULL DEFAULT '0', book_name TEXT NOT NULL);"
Run Code Online (Sandbox Code Playgroud)
它创建表但我尝试插入数据时出现问题.我只是尝试给book_name一个书名,因为我预计book_id的列默认值为0.但它没有,它添加了空值,因此行不会插入.我也试过这个查询:
"CREATE TABLE book(_id INTEGER PRIMARY KEY AUTOINCREMENT, book_id TEXT NOT NULL DEFAULT \'0\', book_name TEXT NOT NULL);"
Run Code Online (Sandbox Code Playgroud)
但问题仍然存在.我已经搜索了堆栈溢出,得到了一些答案,但它们已经老了,现在还不适合我.因此,如何在sqlite中将默认值设置为TEXT列有所改变.提前致谢 :)
编辑
这是插入声明:
database.insert("book", null, cv);
Run Code Online (Sandbox Code Playgroud)
这里cv是ContentValues的对象,它只包含列book_name的值.