我正在开发一个餐厅计划。我遇到了问题。现在我将告诉您产品选择过程中发生的事件
**该应用程序由两个片段组成。活动名称是' MasaDetay'。 FragmentOne名称是' MasaUrunler',FragmentTwo名称是' MasaAdisyon' **
' MasaUrunler'中的操作片段
在' MasaAdisyon'片段,发生以下事件
我正在 onCreateView 中执行LayoutManager事件,并绑定适配器和 RecycleViewAdapter
< / LI>我在 RecyclerViewAdapter 的 getItemCount 函数中查看数组的大小。 在此步骤中,新数据不会进入RecycleViewAdapter
MasaUrunler Kotlin代码
var adapter : MasaAdisyonListesiAdapter? = null
var ADISYONLISTESI = ArrayList<AdisyonListesiBilgileri>()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
var thisView = inflater.inflate(R.layout.fragment_masa_adisyon, container, false)
var args = arguments
var layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
thisView?.findViewById<RecyclerView>(R.id.masaAdisyonListesiRecycle)?.layoutManager = layoutManager
adapter = MasaAdisyonListesiAdapter(ADISYONLISTESI)
if(args?.getSerializable("ADISYONLISTESI") != null){
ADISYONLISTESI = args?.getSerializable("ADISYONLISTESI") as ArrayList<AdisyonListesiBilgileri>
adapter?.notifyDataSetChanged()
}
thisView?.findViewById<RecyclerView>(R.id.masaAdisyonListesiRecycle)?.adapter = adapter
return thisView
}
inner class MasaAdisyonListesiAdapter(_ADISYONLISTESI : ArrayList<AdisyonListesiBilgileri>) : RecyclerView.Adapter<MasaAdisyonListesiAdapter.MasaAdisyonListesiViewHolder>(){
var ADISYONLAR = _ADISYONLISTESI
override fun getItemCount(): Int {
Log.e("ADISYONBOYUTU",ADISYONLAR.size.toString())
return ADISYONLAR.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MasaAdisyonListesiViewHolder {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onBindViewHolder(holder: MasaAdisyonListesiViewHolder, position: Int) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
inner class MasaAdisyonListesiViewHolder(itemView : View) : RecyclerView.ViewHolder(itemView) {
}
}
MasaAdisyon Kotlin代码
String date = "24May2018";
LocalDate ldt = LocalDate.parse(date, DateTimeFormatter.ofPattern("ddMMMyyyy", Locale.US));
String result = ldt.format(DateTimeFormatter.ofPattern("dd-MM-yyyy",Locale.US));
=>24-05-2018
**我希望您的解决方案得到答案。谢谢*