ANDROİD TABLET & DS1307
- By joseph ars
- Apps & Games
- 4 Replies
Hi everyone I have android device which has I2C protocol pins on it and also I have DS1307 real time clock module.How can I read the time from this clock module.Can you help me please ?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_help, container, false)
val thema1: MutableList<String> = ArrayList()
thema1.add("help")
val thema2: MutableList<String> = ArrayList()
thema2.add("help")
val thema3: MutableList<String> = ArrayList()
thema3.add("help")
header.add("Thema 1")
header.add("Thema 2")
header.add("Thema 3")
body.add(thema1)
body.add(thema2)
body.add(thema3)
expandableListView.setAdapter(MyAdapter(context, expandableListView, header, body))
return view
}
override fun onAttach(context: Context) {
super.onAttach(context)
getContext()
}
class MyAdapter(var context: Context,var expandableListView : ExpandableListView,var header : MutableList<String>, var body : MutableList<MutableList<String>>) : BaseExpandableListAdapter(){
override fun getGroup(groupPosition: Int): String {
return header[groupPosition]
}
override fun isChildSelectable(groupPosition: Int, childPosition: Int): Boolean {
return true
}
override fun hasStableIds(): Boolean {
return false
}
override fun getGroupView(groupPosition: Int, isExpanded: Boolean, convertView: View?, parent: ViewGroup?): View? {
var convertView = convertView
if(convertView == null){
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
convertView = inflater.inflate(R.layout.parent_layout,null)
}
val title = convertView?.findViewById<TextView>(R.id.tv_title)
title?.text = getGroup(groupPosition)
title?.setOnClickListener {
if(expandableListView.isGroupExpanded(groupPosition))
expandableListView.collapseGroup(groupPosition)
else
expandableListView.expandGroup(groupPosition)
Toast.makeText(context, getGroup(groupPosition),Toast.LENGTH_SHORT).show()
}
return convertView
}
override fun getChildrenCount(groupPosition: Int): Int {
return body[groupPosition].size
}
override fun getChild(groupPosition: Int, childPosition: Int): String {
return body[groupPosition][childPosition]
}
override fun getGroupId(groupPosition: Int): Long {
return groupPosition.toLong()
}
override fun getChildView(groupPosition: Int, childPosition: Int, isLastChild: Boolean, convertView: View?, parent: ViewGroup?): View? {
var convertView = convertView
if(convertView == null){
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
convertView = inflater.inflate(R.layout.child_layout,null)
}
val title = convertView?.findViewById<TextView>(R.id.tv_title)
title?.text = getChild(groupPosition,childPosition)
title?.setOnClickListener {
Toast.makeText(context, getChild(groupPosition,childPosition),Toast.LENGTH_SHORT).show()
}
return convertView
}
override fun getChildId(groupPosition: Int, childPosition: Int): Long {
return childPosition.toLong()
}
override fun getGroupCount(): Int {
return header.size
}
}
