var data = DataItem()
data.listData = sliderListData
this.data.add(data)
// adapter.notifyDataSetChanged()
// adapter.notifyItemInserted(this.data.size)
}
override fun onItemClick(view: View, data: Any) {
if (data is CategoryData) {
Log.i("TTTT", data.title)
title_page.text=data.title
adapter.clearData()
loadData()
}
if (data is NewsData) {
Log.i("TTTT", data.title)
var intent = Intent(this, DetailActivity::class.java)
intent.putExtra("title",title_page.text.toString())
intent.putExtra("image", data.image)
intent.putExtra("title_d",data.title)
intent.putExtra("description",data.description)
startActivity(intent)
}
if (data is SliderData) {
Log.i("TTTT", data.title)
var intent = Intent(this, DetailActivity::class.java)
intent.putExtra("title",title_page.text.toString())
intent.putExtra("image", data.image)
intent.putExtra("title_d",data.title)
intent.putExtra("description", data.description)
startActivity(intent)
}
}
}
package com.example.newsapp
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_detail.*
class DetailActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_detail)
var bundle = intent.extras
bundle?.let {
title_page.text = it.getString("title")
image.setImageResource(it.getInt("image"))
title_d.text = it.getString("title_d")
description.text = it.getString("description")
}
}
}
package com.example.newsapp.adapters
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.newsapp.R
import com.example.newsapp.models.BaseData
import com.example.newsapp.models.CategoryData
import kotlinx.android.synthetic.main.item_category.view.*
Do'stlaringiz bilan baham: |