片段之间的数据传输

时间:2018-06-06 09:22:54

标签: android android-fragments

我正在开发一个餐厅计划。我遇到了问题。现在我将告诉您产品选择过程中发生的事件

**该应用程序由两个片段组成。活动名称是' MasaDetay'。 FragmentOne名称是' MasaUrunler',FragmentTwo名称是' MasaAdisyon' **

' MasaUrunler'中的操作片段

  1. 我带着Volley带来数据库中的产品,我将它们列在屏幕上,这要归功于RecycleView
  2. 我打印列出的产品,并在另一项活动中选择这些产品的数量,份数和属性
  3. 我获取了onActivityResult函数中的所有数据
  4. 我将数组中保存的数据发送到另一个片段
  5. 在' MasaAdisyon'片段,发生以下事件

    1. 我正在 onCreateView 中执行LayoutManager事件,并绑定适配器 RecycleViewAdapter

      < / LI>
    2. 我在 RecyclerViewAdapter getItemCount 函数中查看数组的大小 在此步骤中,新数据不会进入RecycleViewAdapter

    3. 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
      

      **我希望您的解决方案得到答案。谢谢*

0 个答案:

没有答案
相关问题