问题描述
这有效,但很冗长:
override fun onCreateView(inflater: LayoutInflater,container: ViewGroup?,savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.file_explorer,container,false)
class MyViewHolder(val item: View): RecyclerView.ViewHolder(item) {
init {
item.setonClickListener {
Log.d("path",files[adapterPosition].path)
Log.d("pos",adapterPosition.toString())
goto(files[adapterPosition].path)
}
}
}
val recyclerView = view.findViewById<RecyclerView>(R.id.files)
recyclerView.addItemdecoration(DividerItemdecoration(recyclerView.context,DividerItemdecoration.VERTICAL))
recyclerView.adapter = object: RecyclerView.Adapter<MyViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup,viewType: Int): MyViewHolder {
val item = LayoutInflater.from(parent.context).inflate(R.layout.item,parent,false)
return MyViewHolder(item)
}
override fun onBindViewHolder(holder: MyViewHolder,position: Int) {
holder.item.findViewById<TextView>(R.id.text).text = files[position].name
}
override fun getItemCount() = files.size
}
return view
}
这次尝试:
CREATE TABLE located (
id SERIAL NOT NULL PRIMARY KEY,container_id BIGINT NOT NULL,CONSTRAINT fk_l2c FOREIGN KEY (container_id) REFERENCES containers
);
失败:
CREATE TABLE located (
id SERIAL NOT NULL PRIMARY KEY,container_id BIGINT NOT NULL FOREIGN KEY REFERENCES containers
);
有没有办法在与 container_id 相同的行上声明外键?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)