title: How do I load an item from API to a fragment inside an Activity?
body: <p>I need to load elements from my API to a fragment inside an activity, but once I initialize the element inside of the Activity Class present in the fragment like the TextView the app crashes.</p>
  <p><a href="https://i.stack.imgur.com/tJolj.png" rel="nofollow noreferrer">This is what the property Profile Activity looks like</a></p>
  <p>this is the PropertyProfile Kotlin Code</p>
  <pre><code>val item = intent.getSerializableExtra(&quot;item&quot;) as DemoDataBaseItem
      val url = intent.getStringExtra(&quot;url&quot;)
  
      aboutp = findViewById(R.id.frag_details_text)
      locationp = findViewById(R.id.profile_location)
      profilenametext = findViewById(R.id.profile_property_name)
      profileratingbar = findViewById(R.id.profile_rating_bar)
      profileimageview = findViewById(R.id.imv_property_profile)
      bnow_button = findViewById(R.id.booknow_btn)
      call = findViewById(R.id.call_btn)
  
      aboutp.text = item.about_property
      locationp.text = item.location_country
      profilenametext.text = item.property_name
      profileratingbar.rating = item.rating_bar.toFloat()
      Glide.with(this).load(item.imageurl).centerCrop()
          .into(profileimageview)
  
      call.setOnClickListener {
          //open the call intent
          val intent = Intent(Intent.ACTION_DIAL, Uri.fromParts(&quot;tel&quot;, item.property_phone, null))
          startActivity(intent)
      }
  
      bnow_button.setOnClickListener {
          val intent = Intent(this, Webview::class.java)
          val finalURL = &quot;${item.beurl}#checkin=${checkinText.text}&amp;checkout=${checkoutText.text}&quot;
          intent.putExtra(&quot;item&quot;, item)
          intent.putExtra(&quot;url&quot;, finalURL)
          startActivity(intent)
      }
  </code></pre>
  <p>this is the code in the Main Activity</p>
  <pre><code>    fun getAllData(){
          Api.retrofitService.getAllData().enqueue(object: Callback&lt;List&lt;DemoDataBaseItem&gt;&gt;{
              override fun onResponse(
                  call: Call&lt;List&lt;DemoDataBaseItem&gt;&gt;,
                  response: Response&lt;List&lt;DemoDataBaseItem&gt;&gt;
              ) {
                  if(response.isSuccessful){
                      datalist = response.body()!!.toMutableList()
                      mAdapter = MyAdapter(response.body()!!, this@MainActivity)
                      recyclerView.adapter = mAdapter
  
                  }
  
  
              }
  
  
              //required DO NOT REMOVE, this is for error tracking
              override fun onFailure(call: Call&lt;List&lt;DemoDataBaseItem&gt;&gt;, t: Throwable) {
  
              }
  
          })
  
      }
  
  
          //additional url adding
          override fun onClick(item: DemoDataBaseItem) {
          val intent = Intent(this, PropertyProfile::class.java)
          intent.putExtra(&quot;item&quot;, item)
          startActivity(intent)
      }
  
  
  
  
  
  
  }
  
  
  
  
  
  interface OnClickListener {
      fun onClick(item: DemoDataBaseItem)
  
  }
  </code></pre>
  <p>The code for the Fragment</p>
  <pre><code>import android.os.Bundle
  import androidx.fragment.app.Fragment
  import android.view.LayoutInflater
  import android.view.View
  import android.view.ViewGroup
  import com.cloudbeds.dummyapitest1.R
  
  
  
  class Details : Fragment() {
  
  
      override fun onCreateView(
          inflater: LayoutInflater, container: ViewGroup?,
          savedInstanceState: Bundle?
      ): View? {
          // Inflate the layout for this fragment
          return inflater.inflate(R.layout.fragment_details, container, false)
  
  
      }
  }
  </code></pre>
  <p>I need to load the &quot;about_property&quot; item in the API to the textview in the fragment</p>