0

I've created a custom InfoWindow for my Android app. It's working, I can see my custom data inside it.

I want to know how to make the title and the whole content clickable one at a time ?

I'm generating some data and showing them, I want to be able to click on each textViews that I'm creating.

I've seen that the marker is acting like and image, it there a way to avoid this (when I click on the title, the hole block is getting clicked)

See my InfoWindo :

class InfoWindowCustom(internal var context: Context, internal var mMap: GoogleMap, internal val idItem: String, internal val listeArrets: JSONArray, internal val name : String) : GoogleMap.InfoWindowAdapter {

    internal lateinit var inflater: LayoutInflater
    private val TAG = InfoWindowCustom::class.java.simpleName
    /* some variables ...*/
    override fun getInfoContents(marker: Marker): View? {
        return null
    }

    override fun getInfoWindow(marker: Marker): View {
        inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
        val v = inflater.inflate(R.layout.custom_info_window, null)

        val title = v.findViewById<TextView>(R.id.title)
        title.text = name
        val loader = v.findViewById<TextView>(R.id.loadingArretProxi)
        Log.i("Proximite", "$name infoWindow")
        if(listeArrets.length() > 0){
            loader.visibility = View.GONE
            (0 until listeArrets.length()).forEach   {
                val item = listeArrets.getJSONObject(it)
                val code = item.getString("code")

                val linearLayoutRes = v.findViewById<LinearLayout>(R.id.resMarkerHoraire)
                val linearLayoutResultArret = LinearLayout(this.context)
                linearLayoutResultArret.layoutParams = lpmm
                linearLayoutResultArret.setPadding(30,15,15,15)
                linearLayoutResultArret.setBackgroundColor(colorWhite)
                linearLayoutResultArret.weightSum = 1F
                linearLayoutResultArret.orientation = LinearLayout.HORIZONTAL
                linearLayoutRes.addView(linearLayoutResultArret)

                val ligne = TextView(this.context)
                lpww.weight = 0.1F
                ligne.layoutParams = lpww
                ligne.text = code
                ligne.textAlignment = TextView.TEXT_ALIGNMENT_CENTER
                ligne.background = lignea
                ligne.setTextColor(colorBlack)
            }
        }



        mMap.setOnInfoWindowClickListener {
            val bundle = Bundle()
            bundle.putString("datafirst", idItem)
            bundle.putString("datasecond", marker.title)

            val fragment = Result()
            fragment.arguments = bundle
            val fragmentManager = (context as AppCompatActivity).supportFragmentManager
            val fragmentTransaction = fragmentManager.beginTransaction()

            fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack(null)
            fragmentTransaction.commit()
        }

        return v
    }
}
Projet Sin
  • 337
  • 8
  • 20

0 Answers0