Я выбираю свойства продукта, который я вхожу из FragmentA в другой деятельности.И я сохраняю данные FragmentA, когда закрываю действие.Затем я могу успешно отправить функцию, найденную во FragmentA, функции, найденной во FragmentB.Но я не могу показать это здесь с адаптером RecycleView.Это дает мне эту ошибку No adapter attached; skipping layout
Я делюсь своими кодами. FragmentB - это имя 'MasaAdisyon'
FragmentA:
var ADISYONLISTESI = ArrayList<AdisyonListesiBilgileri>()
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if(requestCode == 1){
var gecici = AdisyonListesiBilgileri(
data?.extras!!.getDouble("MIKTAR"),
data?.extras!!.getDouble("PORSIYON"),
data?.extras!!.getSerializable("URUNANABILGILERI") as UrunBilgileri,
data?.extras!!.getSerializable("SECILENOZELLIKLER") as ArrayList<secilenOzellikler>,
data?.extras!!.getSerializable("OZELLIKLISTESI") as ArrayList<UrunOzellikBilgileri>,
0,
0,
null,
null,
null
)
ADISYONLISTESI.add(gecici)
var bundle = Bundle()
bundle.putSerializable("ADISYONLISTESI",ADISYONLISTESI)
var masaAdisyon = MasaAdisyon()
masaAdisyon.arguments = bundle
var fragmentManager = getFragmentManager()
fragmentManager?.beginTransaction()?.replace(R.id.masaAdisyonFrame, MasaAdisyon())?.commit()
masaAdisyon.adisyonlariListele()
}
}
FragmentB
class MasaAdisyon : Fragment() {
var IPADRES : String? = null
var FIYATTIPI : String? = null
var KASATIPI : String? = null
var adapter : MasaAdisyonListesiAdapter? = null
companion object {
fun newInstance(IPADRES: String?, FIYATTIPI: String?, KASATIPI: String?): MasaAdisyon{
val fragment = MasaAdisyon()
var bundle = Bundle()
bundle.putString("IPADRES",IPADRES)
bundle.putString("FIYATTIPI",FIYATTIPI)
bundle.putString("KASATIPI",KASATIPI)
fragment.arguments = bundle
return fragment
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_masa_adisyon, container, false)
}
var activity : Activity? = null
override fun onAttach(context: Context?) {
super.onAttach(context)
activity = context as Activity
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
IPADRES = arguments?.getString("IPADRES")
FIYATTIPI = arguments?.getString("FIYATTIPI")
KASATIPI = arguments?.getString("KASATIPI")
}
var ADISYONLISTESI = ArrayList<AdisyonListesiBilgileri>()
fun adisyonlariListele(){
var args = arguments
this.ADISYONLISTESI = args?.getSerializable("ADISYONLISTESI") as ArrayList<AdisyonListesiBilgileri>
this.adapter = MasaAdisyonListesiAdapter(this.ADISYONLISTESI)
var layoutManager = LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)
activity?.findViewById<RecyclerView>(R.id.ADISYONLISTESIRECYCLE)?.layoutManager = layoutManager
activity?.findViewById<RecyclerView>(R.id.ADISYONLISTESIRECYCLE)?.adapter = this.adapter
}}
getItemCount дает мне 0. Однако массив во FragmentB не пустой.По какому пути я должен следовать?