2 Botones setOnClickListener

AlexxxBcN Seguir

Gamma
Verificación en dos pasos desactivada
Verificado por Whatsapp
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
Desde
18 Feb 2013
Mensajes
421
Hola , tengo mBtnShare boton para compartir , he añadido otro boton , pero no me funciona , como podria hacer que me funcionará el boton mBtnwa ?

Alguna idea o ayuda ? Gracias


Insertar CODE, HTML o PHP:
class About : AppCompatActivity()  {


    @SuppressLint("SetTextI18n")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_about)

        val mTextView: TextView = findViewById(R.id.textView)
        val mBtnShare: Button = findViewById(R.id.btnShare)

          mBtnShare.setOnClickListener {
            val s = mTextView.text.toString()
            val sharingIntent = Intent(Intent.ACTION_SEND)
            sharingIntent.type = "text/plain"
            sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject Here")
            sharingIntent.putExtra(Intent.EXTRA_TEXT, s)
            startActivity(Intent.createChooser(sharingIntent, "Share text via")
            )


            mBtnwa.setOnClickListener {
                val url = "https://api.whatsapp.com/send?phone=$00 000000000"
                val mBtnwa = Intent(Intent.ACTION_VIEW)
                mBtnwa.data = Uri.parse(url)
                startActivity(mBtnwa)
            }


        }


En el layout no se si me faltaría un textView2

<Button android:id="@+id/[B]mBtnwa[/B]" android:text="Send" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#24d547" android:layout_marginTop="25dp"/> <TextView android:id="@+id/[B]textView[/B]" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="share " android:visibility="gone"/> <Button android:id="@+id/[B]btnShare[/B]" android:text="Click para compartir la App" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#24d547" android:layout_gravity="center" />
 

¡Regístrate y comienza a ganar!

Beneficios

  • Gana dinero por participar
  • Gana dinero por recomendarnos
  • Descubre ofertas de empleo diariamente
  • Negocios seguros
  • ¡Información premium y más!

Acceder

¿Ya tienes una cuenta? Accede aquí

Arriba