Im trying to biuld a simple android auto application.
I found some samples for "hello world" project.. but thats it. Cannot find anything for creating a listview (for contacts) or any other views.. Is it possible?
Im trying to biuld a simple android auto application.
I found some samples for "hello world" project.. but thats it. Cannot find anything for creating a listview (for contacts) or any other views.. Is it possible?
This is an example:
private val predictionRows: MutableList<Row> = mutableListOf()
private val mIcon = IconCompat.createWithResource(
getCarContext(),
R.drawable.ic_cog
)
init {
val firstRoute = SpannableString(" \u00b7 Shortest route")
firstRoute.setSpan(DurationSpan.create(TimeUnit.HOURS.toSeconds(26)), 0, 1, 0)
val secondRoute = SpannableString(" \u00b7 Less busy")
secondRoute.setSpan(DurationSpan.create(TimeUnit.HOURS.toSeconds(24)), 0, 1, 0)
val thirdRoute = SpannableString(" \u00b7 HOV friendly")
thirdRoute.setSpan(DurationSpan.create(TimeUnit.MINUTES.toSeconds(867)), 0, 1, 0)
predictionRows.add(Row.Builder()
.setTitle(firstRoute)
.addText("Via NE 8th Street")
.addText("Another row")
.setImage(CarIcon.Builder(mIcon).build())
.build())
predictionRows.add(Row.Builder().setTitle(secondRoute).addText("Via NE 1st Ave").build())
predictionRows.add(Row.Builder().setTitle(thirdRoute).addText("Via NE 4th Street").build())
}
override fun onGetTemplate(): Template {
val listBuilder = ItemList.Builder()
listBuilder.setOnSelectedListener(this::onItemSelected)
.setOnItemsVisibilityChangedListener(this::onItemVisibilityChanged)
predictionRows.forEach {
listBuilder.addItem(it)
}
return ListTemplate.Builder()
.setSingleList(listBuilder.build())
.setHeaderAction(Action.BACK)
.setTitle("Predictions:")
.build()
}