I'm writing code to use multiple viewtype. But also I have to do inflate TextView.
I wanna inflate holder.participant using loop.
The raw data of participant is "AAA#BBB#CCC". using split method, I wanna inflate TextView.
what should I do for this? what I wanna say is how to inflate TextView or other views, not multiple viewtype.
class ScheduleAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
lateinit var view : View
lateinit var itemList: ArrayList<ScheduleItem>
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val context = parent.context
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
if(viewType == HEADER_TYPE){
view = inflater.inflate(R.layout.schedule_header,parent,false)
return HeaderViewHolder(view)
}
else if(viewType == ITEM_TYPE){
view = inflater.inflate(R.layout.schedule_item,parent,false)
return ItemViewHolder(view)
}else{
return HeaderViewHolder(view)
}
}
override fun getItemCount(): Int = itemList.size
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
if(holder is HeaderViewHolder){
holder.startDay.text = itemList.get(position).startDay
}else if(holder is ItemViewHolder){
holder.time.text = itemList.get(position).startTime+"~"+itemList.get(position).endTime
holder.title.text = itemList.get(position).title
holder.participant.text = itemList.get(position).participant
holder.title.text = itemList.get(position).title
}
}
inner class HeaderViewHolder internal constructor(itemView: View) :
RecyclerView.ViewHolder(itemView) {
internal var startDay: TextView
init {
startDay = itemView.findViewById(R.id.startDay)
}
}
inner class ItemViewHolder internal constructor(itemView: View) :
RecyclerView.ViewHolder(itemView) {
internal var time: TextView
internal var title: TextView
internal var participant: TextView
internal var place: TextView
init {
time = itemView.findViewById(R.id.time)
title = itemView.findViewById(R.id.title)
participant = itemView.findViewById(R.id.participant)
place = itemView.findViewById(R.id.place)
}
}
fun addItems(items : ArrayList<ScheduleItem>){
items.addAll(items)
}
}
I did some corrections to your code. Maybe will help you
class ScheduleAdapter : RecyclerView.Adapter<ScheduleAdapter.BaseViewHolder>() {
private val itemsList = mutableListOf<ScheduleItem>()
override fun getItemCount(): Int = itemList.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
return when (viewType) {
HEADER_TYPE -> HeaderViewHolder.create(parent)
ITEM_TYPE -> ItemViewHolder.create(parent)
// TEXT_TYPE -> TextItemHolder.create(parent)
}
}
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
holder.bind(itemsList.get(position))
}
fun addItems(items: Collection<ScheduleItem>) {
itemsList.addAll(items)
notifyDataSetChanged()
}
fun clear() {
itemsList.clear()
notifyDataSetChanged()
}
abstract internal class BaseViewHolder
internal constructor(itemView: View) : RecyclerView.ViewHolder(itemView) {
abstract fun bind(item: ScheduleItem);
}
internal class HeaderViewHolder
internal constructor(itemView: View): BaseViewHolder(itemView) {
internal var startDay: TextView
init {
// initialize here your views
}
override fun bind(item: ScheduleItem) {
startDay.text = item.startDay
}
companion object {
#JvmStatic
fun create(container: ViewGroup): HeaderViewHolder {
val inflater = LayoutInflater.from(container.context)
return HeaderViewHolder(
inflater.inlate(R.layout.schedule_header), container, false
)
}
}
}
internal class ItemViewHolder
internal constructor(itemView: View): BaseViewHolder(itemView) {
internal var time: TextView
internal var title: TextView
internal var participant: TextView
internal var place: TextView
init {
// initialize here your views
}
override fun bind(item: ScheduleItem) {
time.text = item.startTime+"~"+item.endTime
title.text = item.title
participant.text = item.participant
title.text = item.title
}
companion object {
#JvmStatic
fun create(container: ViewGroup): ItemViewHolder {
val inflater = LayoutInflater.from(container.context)
return ItemViewHolder(
inflater.inlate(R.layout.schedule_item), container, false
)
}
}
}
internal class TextItemHolder
internal constructor(val textView: TextView): BaseViewHolder(textView) {
override fun bind(item: ScheduleItem) {
textView.text = "Set your values here"
}
companion object {
#JvmStatic
fun create(container: ViewGroup): TextItemHolder {
val textView = TextView(container.context)
textView.layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
return TextItemHolder(textView)
}
}
}
}
P.S: I didn't test this code on my machine. There might be some syntax errors :)
Related
I'm trying to pass my binding variable for the adapter to the ViewHolder to assing values to the textviews in my adapter but the values are not assigned and the click listeners dont do anything.
Here's my adapter class:
class DoneAppointmentsAdapter(var context: DoneAppointmentsFragment, listener: ContentListener, var arrayList: List<Appointment>) :
RecyclerView.Adapter<DoneAppointmentsAdapter.ItemHolder>() {
private val listener: ContentListener = listener
private var binding: DoneAppointmentsAdapterBinding? = null
var activity = context
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): ItemHolder {
val viewHolder = LayoutInflater.from(parent.context)
.inflate(R.layout.done_appointments_adapter, parent, false)
binding = DoneAppointmentsAdapterBinding.inflate(LayoutInflater.from(parent.context))
return ItemHolder(viewHolder,binding, parent.context)
}
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
holder.bind(arrayList, listener)
}
override fun getItemCount(): Int {
return arrayList.size
}
class ItemHolder(view: View, var binding: DoneAppointmentsAdapterBinding?, val context: Context) : RecyclerView.ViewHolder(view) {
fun bind(listOfData: List<Appointment>, listener: ContentListener) {
val dataListItem = listOfData[adapterPosition]
binding?.donePatientItemName?.text = "${dataListItem.patientName}"
binding?.donePatientItemTime?.text = "Some date"
binding?.donePatientItemPatientInfo?.setOnClickListener {
tempAppointmentId = dataListItem.id
listener.onPatientHistoryViewClicked(dataListItem.requestedBy)
}
binding?.donePatientItemReviewCase?.setOnClickListener {
amendPrescriptionWarning(dataListItem,context)
}
binding.donePatientItemViewCase.setOnClickListener {
startPreview(dataListItem)
}
}
}
}
You have messed up inside onCreateViewHolder . you have created view twice once with the LayoutInflater.from(parent.context) and once with DoneAppointmentsAdapterBinding.inflate . There should be only one in this case onlyDoneAppointmentsAdapterBinding .
class DoneAppointmentsAdapter(var context: DoneAppointmentsFragment, listener: ContentListener, var arrayList: List<Appointment>) :
RecyclerView.Adapter<DoneAppointmentsAdapter.ItemHolder>() {
private val listener: ContentListener = listener
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): ItemHolder {
val binding = DoneAppointmentsAdapterBinding.inflate(LayoutInflater.from(parent.context))
return ItemHolder(binding)
}
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
holder.bind(arrayList, listener)
}
override fun getItemCount(): Int {
return arrayList.size
}
class ItemHolder (var binding: DoneAppointmentsAdapterBinding) : RecyclerView.ViewHolder(binding.root) {
fun bind(listOfData: List<Appointment>, listener: ContentListener) {
val dataListItem = listOfData[adapterPosition]
binding.donePatientItemName.text = "${dataListItem.patientName}"
binding.donePatientItemTime.text = "Some date"
binding.donePatientItemPatientInfo.setOnClickListener {
tempAppointmentId = dataListItem.id
listener.onPatientHistoryViewClicked(dataListItem.requestedBy)
}
binding.donePatientItemReviewCase.setOnClickListener {
amendPrescriptionWarning(dataListItem,binding.donePatientItemReviewCase.context)
}
binding.donePatientItemViewCase.setOnClickListener {
startPreview(dataListItem)
}
}
}
}
It should be like this . I have also removed extra useless arguments from ItemHolder .
To make it clear the problem with your code was RecyclerView.ViewHolder(view) you were passing view while you were doing all action and stuff on binding those holds are two different instances of View . Which should be fixed with above code.
So I created a RecyclerView to generate beverage items and for some reason my recycler veiw keeps on repeating the first item.
I tried using
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
while using
holder.itemView.text_view1.text = user.name
holder.itemView.text_view2.text = user.name
holder.itemView.text_View3.text = user.name
and the the results are the same.
What's causing the repetition?
BeverageAdapter.kt
class BeverageAdapter(val List:ArrayList<Beverage>)
RecyclerView.Adapter<BeverageAdapter.ViewHolder>() {
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val textViewName2 = itemView.findViewById(R.id.text_view1) as TextView
val texViewName3 = itemView.findViewById(R.id.text_view2) as TextView
val textViewHello = itemView.findViewById(R.id.text_View3) as TextView
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val v = LayoutInflater.from(parent.context).inflate(R.layout.list_activity, parent, false)
return ViewHolder(v)
}
override fun getItemCount(): Int {
return List.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val user: Beverage = List[position]
holder.textViewName2.text = user.name
holder.texViewName3.text = user.name
holder.textViewHello.text = user.name
}
}
Beverage.kt
data class Beverage(val name: String)
MainActivity.kt
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val recyclerView = findViewById<RecyclerView>(R.id.item_recycler_view)
recyclerView.setLayoutManager(LinearLayoutManager(this))
val users = ArrayList<Beverage> ()
users.add(Beverage("Coke"))
users.add(Beverage("Gingerale"))
users.add(Beverage("Rootbeer"))
val adapter = BeverageAdapter(users)
recyclerView.adapter = adapter
}
}
Don't use 3 different TextView .
Just use single TextView and set it in Adapter.
RecyclerView.Adapter<BeverageAdapter.ViewHolder>() {
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val textViewName1 = itemView.findViewById(R.id.text_view1) as TextView
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val v = LayoutInflater.from(parent.context).inflate(R.layout.list_activity, parent, false)
return ViewHolder(v)
}
override fun getItemCount(): Int {
return List.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val user: Beverage = List[position]
holder.textViewName1.text = user.name
}
}
In RecyclerView basically you create one view and it repeats as many as data is there.
I have simple RecyclerViewAdapter class:
class TariffsCardAdapter(context: Context, tariffCardItems: List<ItemsItem?>?) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private var context: Context? = null
private var tariffCardItems: ArrayList<ItemsItem?>? = null
init {
this.context=context
this.tariffCardItems=tariffCardItems as ArrayList<ItemsItem?>
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.layout_tariff_card_items, parent, false)
return TariffsCardAdapterViewHolder(view)
}
override fun getItemCount(): Int {
return tariffCardItems!!.size
}//getItemCount ends
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val viewHolder = holder as TariffsCardAdapterViewHolder
Log.e("posX","pos:::".plus(position))
}
private inner class TariffsCardAdapterViewHolder : RecyclerView.ViewHolder {
var text: TextView? = null
constructor(row: View) : super(row) {
text= row.findViewById(R.id.text) as TextView
}
}
}
Now lets suppose that my tariffCardItems: List<ItemsItem?> will have only 5 items in the list that I want to show.
The problem is that when the adapter gets instantiated that is for the first time the onBindViewHolder method is called twice.
So that the Log values prints as:
pos:::0
pos:::1
pos:::0
pos:::1
Which means that my recycler view position will be 1 in the end.
And the very first view will be created with list item at index 1 which is wrong and should be `0.
In other words, the very first child of the recycler view is created by 1 position value which is wrong.
What am I doing wrong?
It's simply because you are calling adapter 2 in code an recyclerview's bindviewholder should use to bind data not to call viewholder.
class TariffsCardAdapter(context: Context, tariffCardItems: List<ItemsItem?>?) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private var context: Context? = null
private var tariffCardItems: ArrayList<ItemsItem?>? = null
init {
this.context=context
this.tariffCardItems=tariffCardItems as ArrayList<ItemsItem?>
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.layout_tariff_card_items, parent, false)
return TariffsCardAdapterViewHolder(view)
}
override fun getItemCount(): Int {
return tariffCardItems!!.size
}//getItemCount ends
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
//bind data
}
private inner class TariffsCardAdapterViewHolder : RecyclerView.ViewHolder {
var text: TextView? = null
constructor(row: View) : super(row) {
text= row.findViewById(R.id.text) as TextView
}
}
}
For example your adapter should be like this
class CustomAdapter(val userList: ArrayList<User>) : RecyclerView.Adapter<CustomAdapter.ViewHolder>() {
//this method is returning the view for each item in the list
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomAdapter.ViewHolder {
val v = LayoutInflater.from(parent.context).inflate(R.layout.list_layout, parent, false)
return ViewHolder(v)
}
//this method is binding the data on the list
override fun onBindViewHolder(holder: CustomAdapter.ViewHolder, position: Int) {
holder.bindItems(userList[position])
}
//this method is giving the size of the list
override fun getItemCount(): Int {
return userList.size
}
//the class is hodling the list view
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bindItems(user: User) {
val textViewName = itemView.findViewById(R.id.textViewUsername) as TextView
val textViewAddress = itemView.findViewById(R.id.textViewAddress) as TextView
textViewName.text = user.name
textViewAddress.text = user.address
}
}
}
This method from your code is calling twice
val viewHolder = holder as TariffsCardAdapterViewHolder
Log.e("posX","pos:::".plus(position))
I'm trying to use a RecyclerView to show an array of values in CardViews in a specific order i.e. "Title A" & "Subtitle A" in 1 CardView; "Title B" & "Subtitle B" in another. Is there a way to obtain the values from the arrays in my fragment without having to create a new verbose class, or do I have to use a data class to achieve this?
Fragment class
class MyFragment : androidx.fragment.app.Fragment() {
private lateinit var mRecyclerView: RecyclerView
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_rv, container, false)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
val v = view
mRecyclerView = v!!.findViewById<RecyclerView>(R.id.my_recyclerview)
mRecyclerView.layoutManager = LinearLayoutManager(activity)
val myList = mutableListOf(
RVAdapterTConnections.ITEM_A,
RVAdapterTConnections.ITEM_B,
RVAdapterTConnections.ITEM_B
)
val titlesList = mutableListOf(
"Title A",
"Title B"
)
val subtitlesList = mutableListOf(
"Subtitle A",
"Subtitle B"
)
val mAdapter = MyRVAdapter(myList, titlesList)
mRecyclerView.adapter = mAdapter
super.onActivityCreated(savedInstanceState)
}
}
Adapter class
internal class MyRVAdapter(private val listViewType: List<Int>, private val myList: List<CharSequence>) : RecyclerView.Adapter<MyRVAdapter.ViewHolder>() {
companion object {
const val ITEM_A = 1
const val ITEM_B = 2
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val inflater = LayoutInflater.from(parent.context)
return when (viewType) {
ITEM_A -> ViewHolderItemA(inflater.inflate(R.layout.layout_item_a, parent, false))
else -> ViewHolderItemB(inflater.inflate(R.layout.layout_item_b, parent, false))
}
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val viewType = listViewType[position]
when (viewType) {
ITEM_A -> {
val viewHolderA = holder as ViewHolderItemA
viewHolderA.textView.text = "Lorem Ipsum"
}
ITEM_B -> {
val viewHolderB = holder as ViewHolderItemB
viewHolderB.ivExpandCollapse.setImageDrawable(ContextCompat.getDrawable(holder.ivExpandCollapse.context, R.drawable.ic_keyboard_arrow_down))
viewHolderB.tvTitle.text = titlesList[position]
viewHolderB.tvSubtitle.text = subtitlesList[position]
}
else -> {
val viewHolderA = holder as ViewHolderItemA
viewHolderA.textView.text = "Lorem Ipsum"
}
}
}
override fun getItemCount(): Int = listViewType.size
override fun getItemViewType(position: Int): Int = listViewType[position]
open inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
inner class ViewHolderItemA(itemView: View) : ViewHolder(itemView) {
val textView: TextView = itemView.findViewById(R.id.my_custom_tv)
}
inner class ViewHolderItemB(itemView: View) : ViewHolder(itemView) {
val tvTitle: TextView = itemView.findViewById(R.id.tv_title)
val tvSubtitle: TextView = itemView.findViewById(R.id.tv_subtitle)
}
}
Data class
data class MyItem (val title: String, val subtitle: String)
the view-type ordinary can be derived from the data model, most commonly from some type of groupId. these titlesList and subtitlesList need to be replaced; use BaseAdapter to populate the RecyclerView.Adapter. for example (it loads string resources, where SpinnerItem is a simple data model):
abstract class BaseArrayAdapter : BaseAdapter {
private var mItems: ArrayList<SpinnerItem>? = null
private var layoutInflater: LayoutInflater? = null
internal constructor(#NonNull context: Context) {
this.layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
}
internal constructor(#NonNull context: Context, #NonNull #ArrayRes arrayKeys: Int, #NonNull #ArrayRes arrayValues: Int) {
this.layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
this.setItems(context, arrayKeys, arrayValues)
}
#NonNull
#Override
override fun getItem(position: Int): SpinnerItem {
return this.mItems!!.get(position)
}
#Override
override fun getItemId(position: Int): Long {
return this.mItems!!.get(position).id!!
}
#NonNull
#Override
override fun getView(position: Int, #Nullable view: View?, #NonNull parent: ViewGroup): View {
var convertView = view
if (convertView == null) {
convertView = this.layoutInflater!!.inflate(R.layout.support_simple_spinner_dropdown_item, parent, false)
}
convertView!!.setTag(this.mItems!!.get(position))
val textView: TextView = convertView.findViewById(android.R.id.text1)
textView.text = this.mItems!![position].name
textView.setAllCaps(true)
return convertView
}
private fun clearItems() {
if (this.mItems != null) {
this.mItems!!.clear()
} else {
this.mItems = ArrayList()
}
}
internal fun setItems(#NonNull context: Context, #NonNull #ArrayRes arrayKeys: Int, #NonNull #ArrayRes arrayValues: Int) {
this.clearItems()
val res = context.getResources()
val keys = res.getStringArray(arrayKeys)
val values = res.getStringArray(arrayValues)
for (i in keys.indices) {
this.mItems!!.add(i, SpinnerItem((i + 1).toLong(), keys[i], values[i]))
}
}
override fun getCount(): Int {
return this.mItems!!.size
}
}
some sub-class of the abstract class:
class SomeAdapter(#NonNull context: Context) : BaseArrayAdapter(context) {
init {
this.setItems(context, R.array.some_keys, R.array.some_values)
}
}
and then in the RecyclerView.Adapter:
init {
this.setItems(new SomeAdapter(context));
}
I am trying to store the values from retrofit into a database by pressing a AddtoCartButton but app is getting crashed when I press this button. I am able to retrieve the result from retrofit without any issues but onclicklistener is the issue.
Code:
inner class MoviesAdapter : RecyclerView.Adapter<MoviesAdapter.MovieViewHolder>() {
private val movies: MutableList<Movie> = mutableListOf()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MovieViewHolder {
return MovieViewHolder(layoutInflater.inflate(R.layout.item_movie_layout, parent, false))
}
override fun getItemCount(): Int {
return movies.size
}
override fun onBindViewHolder(holder: MovieViewHolder, position: Int) {
holder.bindModel(movies[position])
}
fun setMovies(data: List<Movie>) {
movies.addAll(data)
notifyDataSetChanged()
}
inner class MovieViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val movieGenreTxt : TextView = itemView.findViewById(R.id.movieGenre)
val movieYearTxt : TextView = itemView.findViewById(R.id.movieYear)
val movieAvatarImage : ImageView = itemView.findViewById(R.id.movieAvatar)
val movieDescription: TextView =itemView.findViewById(R.id.movieDescription)
fun bindModel(movie: Movie) {
// movieTitleTxt.text = movie.name
movieGenreTxt.text = movie.menu
movieYearTxt.text = movie.price
Picasso.get().load(movie.picture).into(movieAvatarImage)
movieDescription.text=movie.description
var movieName:String= movie.name!!
var testvar=movie.name.toString()
}
}
}
fun addtocart(view: View)
{
Toast.makeText(context,"Success on Click", Toast.LENGTH_SHORT).show()
print testvar
}
Error:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
Below code solves the purpose.
Code:
inner class MoviesAdapter : RecyclerView.Adapter<MoviesAdapter.MovieViewHolder>() {
private val movies: MutableList<Movie> = mutableListOf()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MovieViewHolder {
return MovieViewHolder(layoutInflater.inflate(R.layout.item_movie_layout, parent, false))
}
override fun getItemCount(): Int {
return movies.size
}
override fun onBindViewHolder(holder: MovieViewHolder, position: Int) {
holder.bindModel(movies[position])
}
fun setMovies(data: List<Movie>) {
movies.addAll(data)
notifyDataSetChanged()
}
inner class MovieViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val movieGenreTxt : TextView = itemView.findViewById(R.id.movieGenre)
val movieYearTxt : TextView = itemView.findViewById(R.id.movieYear)
val movieAvatarImage : ImageView = itemView.findViewById(R.id.movieAvatar)
val movieDescription: TextView =itemView.findViewById(R.id.movieDescription)
fun bindModel(movie: Movie) {
// movieTitleTxt.text = movie.name
movieGenreTxt.text = movie.menu
movieYearTxt.text = movie.price
Picasso.get().load(movie.picture).into(movieAvatarImage)
movieDescription.text=movie.description
var movieName:String= movie.name!!
var testvar=movie.name.toString()
val addtocart = itemView.findViewById<Button>(R.id.idCart)
addtocart!!.setOnClickListener {
print $testvar
Toast.makeText(context,"Success on Click", Toast.LENGTH_SHORT).show()
startActivity(intent) }
}
}
}