klinker24 / Android-FloatingTutorialActivity

A light-weight, easy-to-implement, and easy-to-look-at way to do a tutorial pager or dialog on Android

Home Page:https://blog.klinkerapps.com/floating-tutorial-activity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add multiple element in same page

Paul75 opened this issue · comments

commented

Hello,

It is possible to have in one page and send to activity two elements ?

Exemple :

  • stars
  • EditText

When can I do this ?

thanks

Sorry I don't understand what you mean by that. The pages are just defined by XML attributes, all it really is, is a Fragment. So yes, you can put whatever UI elements you want, into it.

commented

Hello,

Like that :

screenshot_20190130-233215

Can I send to result activity the two elements ?

Thanks

Yes, it is just a normal intent that you are returning to the calling activity. It works the same way as any other activity that provides a result.

commented

yes but means I must do in onclicklistener on my ratingBar ? and on addTextChangedListener for the EditText ?
like :

findViewById<BaseRatingBar>(R.id.rating).setOnRatingChangeListener { baseRatingBar: BaseRatingBar, fl: Float ->
                    val resultData = Intent()
                    resultData.putExtra(RESULT_DATA_STARS, fl)
                    setResult(Activity.RESULT_OK, resultData)
                }

                findViewById<AppCompatEditText>(R.id.editComment).addTextChangedListener(object : TextWatcher {
                    override fun afterTextChanged(p0: Editable?) {
                        val resultData = Intent()
                        resultData.putExtra(RESULT_DATA_COMMENT, p0.toString())
                        setResult(Activity.RESULT_OK, resultData)
                    }

                    override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
                    }

                    override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
                    }
                })

Thanks

You can only set the result once, and you need to include both pieces of data in the intent. I think that you should look up some information on getting the result from the activity. My library does not do it any differently than a generic Android Activity. It uses the exact same system.

https://developer.android.com/training/basics/intents/result

val resultData = Intent()
resultData.putExtra(RESULT_DATA_STARS, stars)
resultData.putExtra(RESULT_DATA_COMMENT, editComment.text.toString())
setResult(Activity.RESULT_OK, resultData)
commented

strenge that when I do in the my post works I retreive all the two element ...