Our problem is displaying records from a SQLite database on an activity. We are able to write data to the database we verified that the data is written with DBBrowser. The other part of this issue is the RecyclerAdapter. We have spent two days construction the syntax. The program flow is simple one line of EditText is saved then we navigate to the PersonActivity that should display the saved data.
In the PersonActivity we query the database for all records and return a contactList. Our Design is MVC, We will post the code below for the DBHelper and the RecyclerAdapter and the PersonActivity to display the data with the XML files involved. Also the Model Class.
class Contact{
var id: Int = 0
var name: String = ""
}
DBHelper insert data and queryAll DB is created no need for all the code
// Start of CRUD functions
fun insert(values: ContentValues): Long {
val Id = db!!.insert(dbTable, null, values)
return Id
}
fun queryAll(): List<Contact> {
val contactList = ArrayList<Contact>()
val selectQuery = "SELECT * FROM $dbTable"
val cursor = db!!.rawQuery(selectQuery, null)
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
val contact = Contact()
contact.id = Integer.parseInt(cursor.getString(cursor.getColumnIndex(colId)))
contact.name = cursor.getString(cursor.getColumnIndex(colName))
contactList.add(contact)
} while (cursor.moveToNext())
}
}
cursor.close()
return contactList
}
RecyclerAdapter NOTE comments
class PersonRecyclerAdapter(val context:Context, val
items:List<Contact>):RecyclerView.Adapter<RecyclerView.ViewHolder>(){
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int):
RecyclerView.ViewHolder {
return ViewHolder(LayoutInflater.from(context).inflate(R.layout.single_card, parent, false))
}
override fun getItemCount(): Int {
return items.size
}
override fun onBindViewHolder(viewHolder: RecyclerView.ViewHolder, position: Int) {
val item = items.get(position)
viewHolder.bindItem(item)
//viewHolder.itemName.text = items[position]
// WHAT IS CORRECT SYNTAX FOR LINE OF CODE ABOVE
}
private fun Any.bindItem(item: Contact) {
// AS Added this fun ?
}
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val itemName = view.tvName
}
}
PersonActivity that should display the contactList data
class PersonActivity : AppCompatActivity() {
private var rvRecyclerView: RecyclerView? = null
private var contactList:List<Contact> = ArrayList()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_person)
val names = contactList
rvRecyclerView?.layoutManager = LinearLayoutManager(this)
rvRecyclerView?.setHasFixedSize(true)
rvRecyclerView?.adapter = PersonRecyclerAdapter(this, names)
callHOME()
}
private fun callHOME(){
val db = DBHelper(this)
contactList = db.queryAll()
}
}
XML files for PersonActivity and the inflated file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.androidstackoverflow.kotlincontacts.PersonActivity"
tools:showIn="#layout/activity_person">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/rvRecylerView">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
Inflated view XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/list_new_card"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="2dp"
android:background="#color/colorAccent"
android:orientation="vertical">
<TextView
android:id="#+id/tvName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textColor="#color/color_Black"
android:textSize="20sp"
android:text="#string/app_name"
android:textStyle="bold" />
</LinearLayout>
Please understand we have looked at numerous code variations for this problem!
Before we ask for help. The Questions are two fold
How to show the data on the PersonActivity?
Is the PersonRecyclerAdapter syntax correct?
First of all callHOME() should be called before initializing names variable. That is:
class PersonActivity : AppCompatActivity() {
private var rvRecyclerView: RecyclerView? = null
private var contactList:List<Contact> = ArrayList()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_person)
callHOME()
val names = contactList
rvRecyclerView?.layoutManager = LinearLayoutManager(this)
rvRecyclerView?.setHasFixedSize(true)
rvRecyclerView?.adapter = PersonRecyclerAdapter(this, names)
}
private fun callHOME(){
val db = DBHelper(this)
contactList = db.queryAll()
}
You also extended your PersonalRecyclerAdapter class with wrong RecyclerView.Adapter<Recycler.ViewHolder> you have to use RecyclerView.Adapter<MyViewHolder>.
RecyclerView.Adapter with own ViewHolder as argument, not default view holder.
Using extension function here is overkill and unnecessary. Though could be used as follows..
class PersonRecyclerAdapter(val context:Context, val
items:List<Contact>):RecyclerView.Adapter<MyViewHolder>(){
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int):
MyViewHolder {
return MyViewHolder(LayoutInflater.from(context).inflate(R.layout.single_card,parent, false))
}
override fun getItemCount(): Int {
return items.size
}
override fun onBindViewHolder(viewHolder: MyViewHolder, position:
Int) {
val item = items.get(position)
viewHolder.bindItem(item)
}
private fun MyViewHolder.bindItem(item: Contact) {
itemName.text = item.name
// or use
// itemView.findViewById<TextView>(R.id.tvName).text = item.name
}
}
class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val itemName = view.tvName
}
Instead just use this
class PersonRecyclerAdapter(val context:Context, val
items:List<Contact>):RecyclerView.Adapter<MyViewHolder>(){
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int):
MyViewHolder { return MyViewHolder(LayoutInflater.from(context).inflate(R.layout.single_card, parent, false)) }
override fun getItemCount(): Int {
return items.size
}
override fun onBindViewHolder(viewHolder: MyViewHolder, position: Int) {
val item = items.get(position)
viewHolder.itemName.text = items[position].name
// or use
// viewHolder.itemView.findViewById<TextView>(R.id.tvName).text = item.name
}
}
class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val itemName = view.tvName
}
First off #kumarshivang made some very good suggestions about how to construct RecyclerAdapter and his best point was not to use the inner class. So I will post code here that uses a much cleaner code design for a RecyclerAdapter. Though even with a better constructed RecyclerAdapter our problem of not seeing the stored data was not solved. Because we knew that the data was in the database logic would tell us two things were wrong either the data had no container to show the view OR the data was not available YEP it was the latter and this one line of code in PersonActivity is what was missing.
listItems = db.queryAll()
Here is the cleaner RecyclerAdapter (OFF to the Refactor FACTORY we GO)
Notice the word "card" the author used a CardView widget to display data in the RecyclerView widget.
class HabitsAdapter(val habits:List<Habit>): RecyclerView.Adapter<HabitsAdapter.HabitViewHolder>() {
class HabitViewHolder(val card:View):RecyclerView.ViewHolder(card)
override fun onBindViewHolder(holder: HabitViewHolder, index: Int) {
if(holder != null){
val habit = habits[index]
holder.card.tvTitle.text = habit.title
holder.card.tvDescription.text = habit.description
holder.card.ivINsingle_card.setImageBitmap(habit.image)
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HabitViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.single_card, parent,false)
return HabitViewHolder(view)
}
override fun getItemCount(): Int {
return habits.size
}
}
Related
After seen all the similiar questions, I don't find a solution of my problem, which the description as follows:
In my android app, I use Kotlin as language. In my app, I have a lot of category and each category have a list of products. In my home activity, I create a vertical RecyclerView named "productListOfCategory". In the "productListOfCategory" adapter,a textView to display a category name and a recyclerView to display all related product list. The following code is the description of "ProductListOfProductTypeAdapter" adapter : (ProductType = category)
class ProductListOfProductTypeAdapter(private val context: Context, private val ProductTypeIDWithProduct: Map<String, Array<ProductData>>, private val productTypeDetail: Array<ProductTypeData>)
: RecyclerView.Adapter<ProductListOfProductTypeAdapter.ViewHolder>(),ProductOfProductTypeAdapter.OnItemClickListener{
override fun onItemClick(view: View, viewModel: ProductData) {
val intent = Intent(context,ProductDetail::class.java)
context.startActivity(intent)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_list_product_product_type, parent, false)
return ViewHolder(view)
}
override fun getItemCount() = ProductTypeIDWithProduct.size
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val itemType = ProductTypeIDWithProduct.keys.elementAt(position)
holder.productTypeName.text = getName(itemType)
val arrayProductOfProductType = ProductTypeIDWithProduct[itemType] as ArrayList<ProductData>
holder.productListOfProductType.apply {
holder.productListOfProductType.layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
holder.productListOfProductType.adapter = ProductOfProductTypeAdapter(arrayProductOfProductType,context,this#ProductListOfProductTypeAdapter)
}
}
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val productTypeName: TextView = itemView.textViewProductTypeName
val productListOfProductType: RecyclerView = itemView.recyclerViewProductOfProductType
}
"ProductOfProductTypeAdapter" is the second adapter which the code as the following :
class ProductOfProductTypeAdapter(private val products: ArrayList<ProductData>, private val context: Context,private val mListener: OnItemClickListener)
: RecyclerView.Adapter<ProductOfProductTypeAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_product_featured, parent, false)
return ViewHolder(view)
}
override fun getItemCount() = products.size
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val productItem = products[position] as Map<String, Map<String, String>>
holder.productName.text = productItem["name"]?.get("En").toString()
holder.productWeight.text = productItem["weight"].toString().plus(context.resources.getString(R.string.ml))
holder.productPrice.text = "$".plus(productItem["price"].toString()).plus("/")
holder.productRating.text = productItem["reviewsValue"].toString()
holder.itemView.setOnClickListener {
mListener.onItemClick(holder.itemView, products[position])
notifyDataSetChanged()
}
}
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val productName: TextView = itemView.itemProdFeaturedName
val productPrice: TextView = itemView.itemProdFeaturedPrice
val productImage: ImageView = itemView.itemProdFeaturedImage
val productWeight: TextView = itemView.txtViewWeight
val productRating: TextView = itemView.itemProdFeaturedRate
}
interface OnItemClickListener {
fun onItemClick(view: View,viewModel: Map<String, Map<String, String>>)
}
My problem is How to click on product and dispaly the product detail activity.I try as the following but still not get what I want.
Shouldn't your OnItemClickListener be like the following?
interface OnItemClickListener {
fun onItemClick(view: View, product: ProductData)
}
And you need to change the way you start your ProductDetail activity, and put your product ID or something to identify the product selected in the extra data of the intent. For example:
val intent = Intent(context,ProductDetail::class.java)
intent.putExtra("PRODUCT_ID", product.id)
context.startActivity(intent)
I'm new to Android development (and Kotlin).
I'm trying to implement a RecyclerView (which works fine) and when I click on a specific row it opens a new activity (Intent).
However, whenever I've press/click on one of the rows, I'm only able to get the value "-1" returned.
I've tried a number of different approaches (you should see the number of tabs in my browser).
This seems like it should be a fairly straightforward occurrence for something as common as a RecyclerView, but for whatever reason I'm unable to get it working.
Here is my RecyclerView Adapter file:
class PNHLePlayerAdapter (val players : ArrayList<PNHLePlayer>, val context: Context) : RecyclerView.Adapter<ViewHolder>() {
var onItemClick: ((Int)->Unit) = {}
// Gets the number of items in the list
override fun getItemCount(): Int {
return players.size
}
// Inflates the item views
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val itemView = LayoutInflater.from(context).inflate(
R.layout.pnhle_list_item,
parent,
false
)
val viewHolder = ViewHolder(itemView)
itemView.setOnClickListener {
onItemClick(viewHolder.adapterPosition)
}
return ViewHolder(itemView)
}
// Binds each item in the ArrayList to a view
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.tvPlayerName?.text = players[position].Name
holder.tvPlayerRank?.text = position.toString()
holder.tvPNHLe?.text = players[position].PNHLe.toString()
holder.tvTeam?.text = players[position].Team
holder.ivLeague?.setImageResource(leagueImageID)
}
}
class ViewHolder (view: View) : RecyclerView.ViewHolder(view) {
val linLayout = view.hor1LinearLayout
val ivTeam = view.teamImageView
val tvPlayerName = view.playerNameTextView
val tvPlayerRank = view.rankNumTextView
val tvPNHLe = view.pnhleTextView
val tvTeam = view.teamTextView
val ivLeague = view.leagueImageView
}
As you can see, there is a class property "onItemClick" which uses a lambda as the click callback.
I setOnClickListener in the onCreateViewHolder method after the view is inflated.
Next, in my Activity I add the list to my Adapter and set the call back.
However, every time I 'Toast' the position it is displayed as '-1'.
val adapter = PNHLePlayerAdapter(list, this)
adapter.onItemClick = { position ->
Toast.makeText(this, position.toString(),Toast.LENGTH_SHORT).show()
var intent = Intent(this, PlayerCardActivity::class.java)
//startActivity(intent)
}
rv_player_list.adapter = adapter
Perhaps I'm not thinking about this properly, but shouldn't the position represent the row number of the item out of the RecyclerView???
Ideally, I need to use the position so that I can obtain the correct item from the 'list' (ArrayList) so that I can pass information to my next Activity using the Intent
I found the issue.
Change this line in onCreateViewHolder:
return ViewHolder(itemView)
to this one:
return viewHolder
I would reorganize the adapter like this:
class PNHLePlayerAdapter : androidx.recyclerview.widget.RecyclerView.Adapter<Adapter.ViewHolder>() {
interface AdapterListener {
fun onItemSelected(position: Int?)
}
var players: List<Player> = listOf()
set(value) {
field = value
this.notifyDataSetChanged()
}
var listener: AdapterListener? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_car_selector, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.bind(position)
}
override fun getItemCount(): Int {
return brands.size
}
inner class ViewHolder(view: View): androidx.recyclerview.widget.RecyclerView.ViewHolder(view) {
private var position: Int? = null
private val baseView: LinearLayout? = view.findViewById(R.id.baseView) as LinearLayout?
...
init {
baseView?.setOnClickListener {
listener?.onManufacturerSelected(position)
}
}
fun bind(position: Int) {
this.position = position
...
}
}
}
And from your activity/fragment set the listener as adapter.listener = this, and implement the onItemSelected(position: Int?)
override fun onItemSelected(position: Int?) {
...
}
I have a problem with:
RecyclerView: No adapter attached; skipping layout
I can't define adapter in OnCreate because the list is not ready.
How I can define adapter in OnCreate? or what is a possible solution for resolve my problem?
In onCreate I did:
adapter = MyAdapter(this#MyActivity)
adapter.data = ArrayList()
Then later I just set adapter.date = xxx
In my adapter I have:
class MyAdapter(val activity: MyActivity) :
RecyclerView.Adapter<MyAdapter.BodyViewHolder>() {
var data: MutableList<MyModel>? = null
set(value) {
field = value
notifyDataSetChanged()
}
override fun getItemCount() = data?.size ?: 0
fun ViewGroup.inflate(#LayoutRes layoutRes: Int, attachToRoot: Boolean = false): View {
return LayoutInflater.from(context).inflate(layoutRes, this, attachToRoot)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BodyViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.my_layout, parent, false)
return BodyViewHolder(view)
}
override fun onBindViewHolder(holder: BodyViewHolder, position: Int) {
holder.bindValue(data?.get(position), activity)
}
class BodyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bindValue(record: MyModel?, activity: MyActivity) {
record?.let {
itemView.mTextView.text = ....
}
}
}
}
Worth mentioning that the height of my recycler view is wrap_content
<android.support.v7.widget.RecyclerView
android:id="#+id/mRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
It's totally ok if you don't have data in onCreate. What you need to do is to define the adapter and bind it with your RecyclerView. Once you have data ready, add data to the list in adapter and notify it. Example as below
class MyAdapter: RecyclerView.Adapter<MyViewHolder>() {
private val data = mutableListOf<MyModel>()
override fun getItemCount() = data.count()
fun addData(data : MyModel) {
// add single data the list or call addAll() to add a group of data.
// just remember not to replace the variable
}
fun clearData() {
}
fun deleteData(id: Int) {
}
}
class adpCoba(val context: Context, val datalist:ArrayList<dataCoba>):RecyclerView.Adapter<adpCoba.MyViewHolder>(){
class MyViewHolder (itemView:View):RecyclerView.ViewHolder(itemView){
val text :TextView=itemView.findViewById(R.id.textcoba)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
val itemView = LayoutInflater.from(context).inflate(R.layout.fetch_coba,parent,false)
return MyViewHolder(itemView)
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
val currntItem = datalist [position]
holder.text.text= currntItem.nama
}
override fun getItemCount(): Int {
return datalist.size
}
}
Our question is how to show Parent and Child data from two SQLite DB tables?
We have two tables that are added to two ArrayLists childList and parentList.
Here are the Model Class's for each
class ModelParent {
var idD:Int = 0
var dept:String = ""
var fkD:Int = 0
var children: List<ModelChild> = mutableListOf()
//var children: ArrayList<ModelChild>? = null
//var children: List<ModelChild> by Delegates.notNull()
constructor (children: List<ModelParent>) : this()
companion object {
var globalVar = 1
}
}
class ModelChild {
var idI:Int = 0
var item:String = ""
var fkI:Int = 0
}
We have two Adapters for each table and will post that code
We are able to iterate through the two ArrayList with this code and display the data in the format we would like to show in the ViewActivity.
fun theGET(){
val db = DBHelper(this)
childList = db.queryITEM()
parentList = db.queryDEPT()
var PL = parentList.size
do {
var DEPT: String = parentList[z].dept
var PARENT_LIST_FK = parentList.get(z).fkD
println("========== Dept " + DEPT + " fkD " + PARENT_LIST_FK)
val FK = PARENT_LIST_FK
childList = db.queryALL(FK)
var CL = childList.size
for (a in 0..CL - 1) {
var CHILD_ITEM = childList[a].item
var CHILD_LIST_FK = childList[a].fkI
println("========== item " + CHILD_ITEM+" fkI "+CHILD_LIST_FK)
}
z++
}
while (z <= PL-1)
}
We will post the View Activity
class ViewActivity : AppCompatActivity() {
lateinit var recyclerView: RecyclerView
private var parentList:List<ModelParent> = ArrayList()
private var childList:List<ModelChild> = ArrayList()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_view)
initRecycler()
}// end onCreate
private fun initRecycler() {
val db = DBHelper(this)
childList = db.queryITEM()
parentList = db.queryDEPT()
recyclerView = rv_parent
recyclerView.apply{
layoutManager = LinearLayoutManager(this#ViewActivity, LinearLayout.VERTICAL, false)
adapter = ViewAdapter(parentList)
adapter = ViewChildAdapter(children = childList)
}
}
}
ViewActivity has this XML file
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ViewActivity">
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_parent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.constraint.ConstraintLayout>
The Two Adapters and coresponding XML files
class ViewAdapter(private val parents:List<ModelParent>):RecyclerView.Adapter<ViewAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.the_view,parent,false)
return ViewHolder(view)
}
override fun getItemCount(): Int {
return parents.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val parent = parents[position]
holder.textView.text = parent.dept
holder.recyclerView.apply {
layoutManager = LinearLayoutManager(holder.recyclerView.context, LinearLayout.VERTICAL, false) as RecyclerView.LayoutManager?
adapter = ViewChildAdapter(parent.children!!)
}
}
inner class ViewHolder(itemView : View) : RecyclerView.ViewHolder(itemView){
val recyclerView : RecyclerView = itemView.rv_child
val textView: TextView = itemView.textView
}
}
class ViewChildAdapter(private val children:List<ModelChild>):RecyclerView.Adapter<ViewChildAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.child_recycler,parent,false)
return ViewHolder(view)
}
override fun getItemCount(): Int {
return children.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val child = children[position]
holder.textView.text = child.item
}
inner class ViewHolder(itemView : View) : RecyclerView.ViewHolder(itemView){
val textView : TextView = itemView.child_textView
}
}
Inflated XML files
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="2dp"
card_view:cardBackgroundColor="#fff"
card_view:cardCornerRadius="5dp"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/textView"
style="#style/Base.TextAppearance.AppCompat.Subhead"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/rv_child"
android:layout_alignParentTop="true"
android:padding="20dp"
android:background="#color/color_super_lightGray"
android:text="Dept Header"
android:textColor="#color/color_Purple"
android:textSize="24sp"
android:textStyle="bold" />
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_child"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="70dp"
android:layout_marginBottom="0dp"
android:orientation="horizontal"
android:paddingLeft="4dp"
android:paddingTop="8dp"
tools:layout_editor_absoluteX="74dp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/child_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="32dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="#color/color_Transparent"
android:padding="10dp"
android:text="TextView"
android:textColor="#color/color_Black"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
When the ViewActivity is loaded ONLY the childList is displayed.
We have tried various changes and can not display the parent List though using theGET fun the parentList data is displayed so we know it is in the list.
We can run the fun theGET and crate a new ArrayList that seems futile.
Our concern is that the parentList is displayed and then removed when the childList is displayed.
We do not know how to prove this.
So our question is how to show Parent and Child data in a organized fashion in the View Activity?
We are adding New CODE based on #Cruces answer
Some issues with this code are beyond out understanding
1. We have no way to run the fun join to create the newList
2. Parent and Child ViewHolder can be called only with receiver of containing Class
3. Too many inner Class's and do we need an Outer Nested annotation?
4. or if both parent and child implement an interface a List< IItem > )
We do not know how to write an interface and connect it to the JoinAdapter
While the answer poses new question we feel it better to ask with in this context = Context HUMOR
Here is the FIX for the JoinAdapter
class JoinAdapter(internal var context: Context, val parents: List<ModelParent>) : RecyclerView.Adapter<JoinAdapter.MyViewHolder>() {
val items = mutableListOf<Any>()
init {
parents //parents should be passed as a constructor argument
.forEach {
items.add(it)
items.addAll(it.children)
}
}
override fun getItemCount(): Int = items.size;
fun getItem(position: Int): Any = items[position]
override fun getItemViewType(position: Int): Int = if (getItem(position) is ModelParent) 0 else 1
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
var view: View? = null
if (viewType == 0) {
view = LayoutInflater.from(parent.context).inflate(R.layout.the_view, parent, false)
return ParentViewHolder(view!!)
} else {
view = LayoutInflater.from(parent.context).inflate(R.layout.child_recycler, parent, false)
return ChildViewHolder(view!!)
}
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) = holder.bindData(position, getItem(position))
inner abstract class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
abstract fun bindData(position: Int, item: Any)
}
inner class ParentViewHolder(view: View) : MyViewHolder(view) {
override fun bindData(position: Int, item: Any) {
val parent = item as? ModelParent ?: return
parent.dept
parent.fkD
parent.children
//bind the data here
}
init {
val textView: TextView = view.textView
var editCLICK: RelativeLayout = view.findViewById(R.id.editCLICK) as RelativeLayout
//do the view setup here
}
}
inner class ChildViewHolder(view: View) : MyViewHolder(view) {
init {
val textView : TextView = itemView.child_textView
//do the view setup here
}
override fun bindData(position: Int, item: Any) {
val child = item as? ModelChild ?: return
child.item
child.idI
//bind the data here
}
}
I am going to post the View Activity call to Join Adapter
Code does not FAIL it just shows nothing?
RecyclerAdapter1 = JoinAdapter(parents = ArrayList(),context = applicationContext)
(recyclerView as RecyclerView).adapter = RecyclerAdapter1
Here is the ViewJoinActivity it will load the Parent Data NO Child Data
class ViewJoinActivity : AppCompatActivity() {
lateinit var recyclerView: RecyclerView
private var RecyclerAdapter: JoinAdapter? = null
private var linearLayoutManager: LinearLayoutManager? = null
private val db = DBHelper(this)
private var parentList:List<ModelParent> = ArrayList()
private var childList:List<ModelChild> = ArrayList()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_view_join)
initRecycler()
}// end onCreate
override fun onResume() {
super.onResume()
initDB()
}
private fun initDB() {
parentList = db.queryDEPT()
//childList = db.queryCHILD(1)
childList = db.queryITEM()
// queryCHILD only selects records with a fkI equal to idD
// SEE THE ModelChild and ModelParent
if(parentList.isEmpty()){
title = "No Records in DB"
}else{
title = "Parent List"
}
RecyclerAdapter = JoinAdapter(parents = parentList, context = applicationContext)
(recyclerView as RecyclerView).adapter = RecyclerAdapter
}
private fun initRecycler() {
val db = DBHelper(this)
childList = db.queryITEM()
parentList = db.queryDEPT()
//recyclerView = rv_parent
/*var PL = parentList.size
newList.clear()
do {
var DEPT: String = parentList[z].dept
var ND:String = DEPT
var PARENT_LIST_FK = parentList.get(z).fkD
var PL_ST = ND+" "+PARENT_LIST_FK
newList.add(PL_ST)
println("========== Dept " + DEPT + " fkD " + PARENT_LIST_FK)
val FK = PARENT_LIST_FK
childList = db.queryCHILD(FK)
var CL = childList.size
for (a in 0..CL - 1) {
var CHILD_ITEM = childList[a].item
var NI:String = childList[a].item
var CHILD_LIST_FK = childList[a].fkI
var IL_ST = NI+" "+CHILD_LIST_FK
newList.add(IL_ST)
println("========== item " + CHILD_ITEM+" fkI "+CHILD_LIST_FK)
}
z++
g++
}
while (z <= PL-1)
var ui = newList.size
g=0
for(g in 0..ui-1){
var N2 = newList[g]
if(N2.toString().contains("1")){
println("********************** We Found "+N2)
}
println("############### BOTH = "+N2)
}*/
recyclerView = this.findViewById(R.id.rv_parent)
RecyclerAdapter = JoinAdapter(parents = parentList, context = applicationContext)
linearLayoutManager = LinearLayoutManager(applicationContext)
(recyclerView as RecyclerView).layoutManager = linearLayoutManager!!
//recyclerView.apply {
//layoutManager = LinearLayoutManager(this#ViewJoinActivity, LinearLayout.VERTICAL, false)
//adapter = JoinAdapter(children = childList)
//}
}
}
Calling the Join Adapter from a Activity is the issue? ?
This Activity has a XML associated file with a RecyclerView rv_parent
The way I would do it is flatten the list edit: like this in the constructor
val items : MutableList<Any> = mutableListOf<Any>()
init() {
parents //parents should be passed as a constructor argument
.asSequence() //this is only needed if you want to also order them
.sortedBy { it.idD } //again only if you want to sort them
.forEach {
items.add(it)
items.addAll(it.children)
}
}
I would create a List < Any > (or if both parent and child implement an interface a List< IItem > ) that would contain all the data as you wish to see it, so for example it could look like this:
val items : List<Any> = listOf(parent1, child11,child12,child13,parent2,child12,child13,child14.....etc)
then I would implement a single adapter with multiple view types like this:
override fun getItemCount(): Int {
return items.size
}
fun getItem(position: Int) : Any { //or the interface
return items[position]
}
override getItemViewType (position: Int) : Int {
if (getItem(position) is ModelParent)
return 0
return 1
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
var view : View? = null
if (viewType == 0) {
view = LayoutInflater.from(parent.context).inflate(R.layout.parent_layout,parent,false)
return ParentViewHolder(view);
} else {
view = LayoutInflater.from(parent.context).inflate(R.layout.child_layout,parent,false)
return ChildViewHolder(view);
}
}
and then I would use two view holders to represent how the data is shown for the specific item
inner class ParentViewHolder(itemView : View) : RecyclerView.ViewHolder(itemView){ ...}
inner class ChildViewHolder(itemView : View) : RecyclerView.ViewHolder(itemView){ ...}
after that I could perform different bindings by getting the type of the view ,something like this:
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
if (getItemType(position) == 0) {
(holder as ParentViewHolder).bindData(....)
} else {
(holder as ChildViewHolder).bindData(....)
}
}
edit: Here is the complete adapter I built, it is based on two layout files:
list_item_child:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="2dp"
card_view:cardBackgroundColor="#fff"
card_view:cardCornerRadius="5dp"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true">
<TextView
android:id="#+id/child_item"
style="#style/Base.TextAppearance.AppCompat.Display3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:padding="20dp"
android:textSize="24sp"
android:textStyle="bold"
tools:text="Dept Header" />
</android.support.v7.widget.CardView>
list_item_parent:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="2dp"
card_view:cardBackgroundColor="#fff"
card_view:cardCornerRadius="5dp"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true">
<TextView
android:id="#+id/parent_department"
style="#style/Base.TextAppearance.AppCompat.Headline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:padding="20dp"
tools:text="Dept Header"
android:textSize="24sp"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
and the adapter would look something like this:
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
data class ModelParent(val id: Int, val children: List<ModelChild>)
data class ModelChild(val id: Int)
class JoinAdapter(internal var context: Context, val parents: List<ModelParent>) : RecyclerView.Adapter<JoinAdapter.MyViewHolder>() {
val items = mutableListOf<Any>()
init {
parents //parents should be passed as a constructor argument
.forEach {
items.add(it)
items.addAll(it.children)
}
}
override fun getItemCount(): Int = items.size;
fun getItem(position: Int): Any = items[position]
override fun getItemViewType(position: Int): Int = if (getItem(position) is ModelParent) 0 else 1
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
var view: View? = null
if (viewType == 0) {
view = LayoutInflater.from(parent.context).inflate(R.layout.rv_list_item_parent, parent, false)
return ParentViewHolder(view!!)
} else {
view = LayoutInflater.from(parent.context).inflate(R.layout.rv_list_item_child, parent, false)
return ChildViewHolder(view!!)
}
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) = holder.bindData(position, getItem(position))
inner abstract class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
abstract fun bindData(position: Int, item: Any)
}
inner class ParentViewHolder(view: View) : MyViewHolder(view) {
var parentDept: TextView = view.findViewById(R.id.parent_department) as TextView
override fun bindData(position: Int, item: Any) {
val parent = item as? ModelParent ?: return
parentDept.text = parent.dept
}
}
inner class ChildViewHolder(view: View) : MyViewHolder(view) {
var childItem: TextView = view.findViewById(R.id.child_item) as TextView
override fun bindData(position: Int, item: Any) {
val child = item as? ModelChild ?: return
childItem.text = child.item
}
}
}
this when used on a single recyclerview will display all children under their parent in a list
Here is a answer and some observations about the design of this app
The answer does NOT place both the parent and child data on the same Recycler View List But the answer may help to solve the issue With further exploration!
What we did was create the parent list and when the Parent Dept is clicked on the corresponding Child Items will be displayed. This may be a more functional design while shopping you only need to look at Produce items while in that section. This means less scrolling through a single master list of Parents and Children.
A word or two about the design we are guessing a grocery store might have 20 or more Departments (Parents) so how you plan to know which Items (Child data) is connected to the appropriate Dept (Parent) needs drastic redesign when building these two lists.
If you downloaded the code from GitHub you will have a better grasp about this design deficiency
Here is all the code with the XML files
Main Activity navigates to View Activity
fun onViewAll(view: View){
val intent = Intent(this,ViewActivity::class.java)
intent.putExtra("pickADAPTER",2)
startActivity(intent)
}
Here is the View Activity
class ViewActivity : AppCompatActivity() {
lateinit var recyclerView: RecyclerView
private var RecyclerAdapter1: ViewAdapter? = null
private var RecyclerAdapter2: ViewChildAdapter? = null
private var linearLayoutManager: LinearLayoutManager? = null
private val db = DBHelper(this)
private var parentList:List<ModelParent> = ArrayList()
private var childList:List<ModelChild> = ArrayList()
var idD = 0
var whichADAPTER = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_view)
val bundle: Bundle = intent.extras
idD = bundle.getInt("BIGi", 0)
whichADAPTER = bundle.getInt("pickADAPTER",0)
initRecycler()
}// end onCreate
override fun onResume() {
super.onResume()
initDB()
}
private fun initDB() {
parentList = db.queryDEPT()
childList = db.queryCHILD(idD)
// queryCHILD only selects records with a fkI equal to idD
// SEE THE ModelChild and ModelParent
if(parentList.isEmpty()){
title = "No Records in DB"
}else{
title = "Parent List"
}
if(whichADAPTER == 2) {
RecyclerAdapter1 = ViewAdapter(parents = parentList, context = applicationContext)
(recyclerView as RecyclerView).adapter = RecyclerAdapter1
}else{
RecyclerAdapter2 = ViewChildAdapter(children = childList)
(recyclerView as RecyclerView).adapter = RecyclerAdapter2
}
}
private fun initRecycler() {
val db = DBHelper(this)
childList = db.queryITEM()
parentList = db.queryDEPT()
recyclerView = rv_parent
recyclerView = this.findViewById(R.id.rv_parent)
RecyclerAdapter1 = ViewAdapter(parents = parentList, context = applicationContext)
linearLayoutManager = LinearLayoutManager(applicationContext)
(recyclerView as RecyclerView).layoutManager = linearLayoutManager!!
}
Here the XML file for View Activity
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_parent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Here is the View Adapter
class ViewAdapter(private val parents: List<ModelParent>, internal var context: Context):RecyclerView.Adapter<ViewAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.the_view,parent,false)
return ViewHolder(view)
}
override fun getItemCount(): Int {
return parents.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val parent = parents[position]
holder.textView.text = parent.dept
holder.editCLICK.setOnClickListener {
val i = Intent(context, ViewActivity::class.java)
i.putExtra("BIGi",parent.idD)
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(i)
}
}
inner class ViewHolder(itemView : View) : RecyclerView.ViewHolder(itemView){
//val recyclerView : RecyclerView = itemView.rv_child
val textView: TextView = itemView.textView
var editCLICK: RelativeLayout = itemView.findViewById(R.id.editCLICK) as
RelativeLayout
And the inflated XML
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="2dp"
card_view:cardBackgroundColor="#FF0000"
card_view:cardCornerRadius="5dp"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true">
<RelativeLayout
android:id="#+id/editCLICK"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/textView"
style="#style/Base.TextAppearance.AppCompat.Subhead"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/rv_child"
android:layout_alignParentTop="true"
android:padding="10dp"
android:background="#color/color_lightGray"
android:text="Dept Header"
android:textColor="#color/color_Purple"
android:textSize="24sp"
android:textStyle="bold" />
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_child"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="50dp"
android:layout_marginBottom="0dp"
android:orientation="horizontal"
android:paddingLeft="4dp"
android:paddingTop="6dp"
tools:layout_editor_absoluteX="74dp" />
</RelativeLayout>
This is the search routine in DBHelper
fun queryCHILD(fkI: Int): List<ModelChild> {
val db = this.writableDatabase
val childList = ArrayList<ModelChild>()
val selectQuery = "SELECT * FROM $CHILD_TABLE WHERE $colCFK = ?"
val cursor = db.rawQuery(selectQuery, arrayOf(fkI.toString()))
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
val contact = ModelChild()
contact.idI = Integer.parseInt(cursor.getString(cursor.getColumnIndex(colidI)))
contact.item = cursor.getString(cursor.getColumnIndex(colItem))
contact.fkI = Integer.parseInt(cursor.getString(cursor.getColumnIndex(colCFK)))
childList.add(contact)
} while (cursor.moveToNext())
}
}
cursor.close()
return childList
}
One thing to make note of we attached the OnClickListener to a Relative Layout
holder.editCLICK.setOnClickListener
Why we are not sure you can obtain parent.idD type information from a RecyclerView set as a listener?
We need to explore this but in our testing the code failed when we tried.
In the ViewActivity class, you have first set the recyclerView adapter to ViewAdapter and then to ViewChildAdapter thus, now, the adapter of recyclerView is ViewChildAdapter instead of ViewAdapter. Remove this line and the problem will be resolved.
How can I use setOnItemClickListner in each item in my ListView?
my xml :
<ListView
android:id="#+id/tv1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
this my adapter class
inner class mo3d1Adapter : BaseAdapter {
override fun getItemId(p0: Int): Long {
return p0.toLong()
}
override fun getCount(): Int {
return listOfmo3d.size
}
var listOfMkabala = ArrayList<MeetingDetails>()
var context: Context? = null
constructor(context: Context, listOfMkabaln: ArrayList<MeetingDetails>) : super() {
this.listOfMkabala = listOfMkabaln
this.context = context
}
override fun getView(p0: Int, p1: View?, p2: ViewGroup?): View {
val mo3d = listOfmo3d[p0]
var inflatormo3d = context!!.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
var myViewmo3d = inflatormo3d.inflate(R.layout.fragment_item, null)
lvMo3d.onItemClickListener = AdapterView.OnItemClickListener { adapterView, view, i, l ->
Toast.makeText(context, " TEST STACK ", Toast.LENGTH_LONG).show()
}
myViewmo3d.meeting_name.text = mo3d.name1!!
myViewmo3d.meeting_date.text = mo3d.date.toString()!!
myViewmo3d.attendance_number.text = mo3d.n2.toString()!!
return myViewmo3d
}
override fun getItem(p0: Int): Any {
return listOfmo3d[p0]
}
}
I want listener for each item in my ListView
And when I used this method setOnClickListener in adapter it's not working, where can I use?
Try this in your activity class
lv.setOnItemClickListener { parent, view, position, id ->
Toast.makeText(this, "Position Clicked:"+" "+position,Toast.LENGTH_SHORT).show()
}
Although a little quirky this works fine for me.
latestMessagesAdapter.setOnItemLongClickListener { item, view ->
val row = item as LatestMessageRow
return#setOnItemLongClickListener(true)
}
First of all I would like to tell that it is RecyclerView rather than ListView. You can find plenty information why to do in such. For example you can read it hear :
RecyclerView vs. ListView
Regarding your question how to do it in correct way with RecyclerView.
Insert dependencies with RecyclerView, they are now in support library in Kotlin.
implementation "com.android.support:appcompat-v7:25.4.0"
First change your ListView with RecyclerView in xml layout like this:
<android.support.v7.widget.RecyclerView
android:id="#+id/accountList"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
Create Adapter for RecyclerView:
class AccountListAdapter(val accountList: AccountList, val itemListener: (Account) -> Unit) :
RecyclerView.Adapter<AccountListAdapter.ViewHolder>(){
override fun getItemCount(): Int = accountList.size
override fun onBindViewHolder(holder: ViewHolder, position: Int) =
holder.bind(accountList[position])
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder{
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_account, parent, false)
return ViewHolder(view, itemListener)
}
class ViewHolder(itemView: View, val itemClick: (Account) -> Unit): RecyclerView.ViewHolder(itemView){
fun bind(account : Account){
with(account){
itemView.accountName.text = title
itemView.setOnClickListener{ itemClick(this)}
}
}
}
}
item_account.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/accountName"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Models (in Kotlin you can put them in one file and name for example AccountModels.kt) :
data class AccountList(val accounts: List<Account>){
val size : Int
get() = accounts.size
operator fun get(position: Int) = accounts[position]
}
data class Account(val id : Long, val title : String, val balance : Int, val defCurrency: Int)
In Fragment/Activity connect your Adapter to RecyclerView:
override fun onStart() {
super.onStart()
setupAdapter()
}
fun setupAdapter(){
Log.d(TAG, "updating ui..")
val account1 = Account(1,"Credit", 1000, 2)
val account2 = Account(2, "Debit", 500, 2)
val account3 = Account(3, "Cash", 7000, 2)
val accounts : List<Account> = listOf(account1, account2, account3)
val adapter = AccountListAdapter(AccountList(accounts)){
val title = it.title
Log.d(TAG, "$title clicked")
}
accountList.layoutManager = LinearLayoutManager(activity)
accountList.adapter = adapter
}
That is all. Everything should work now. Hope it helps.