ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?

ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?

ืื ื• ืžืกืคืจื™ื ืœื›ื ื›ื™ืฆื“ ืœื™ืฆื•ืจ ืืคืœื™ืงืฆื™ื” ืคืฉื•ื˜ื” ืœื—ื™ืฉื•ื‘ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ. ืœื™ืชืจ ื“ื™ื•ืง, ืงื•ื˜ืœื™ืŸ 1.3.21, ืื ื“ืจื•ืื™ื“ 4, ืื ื“ืจื•ืื™ื“ ืกื˜ื•ื“ื™ื• 3. ื”ืžืืžืจ ื™ื”ื™ื” ืžืขื ื™ื™ืŸ, ืงื•ื“ื ื›ืœ, ืœืžื™ ืฉืžืชื—ื™ืœ ืืช ื“ืจื›ื• ื‘ืคื™ืชื•ื— ืืคืœื™ืงืฆื™ื•ืช ืื ื“ืจื•ืื™ื“. ื–ื” ืžืืคืฉืจ ืœืš ืœื”ื‘ื™ืŸ ืžื” ื•ืื™ืš ื–ื” ืขื•ื‘ื“ ื‘ืชื•ืš ื”ืืคืœื™ืงืฆื™ื”.

ืžื—ืฉื‘ื•ืŸ ื–ื” ื™ื”ื™ื” ืฉื™ืžื•ืฉื™ ื›ืืฉืจ ืชืฆื˜ืจื›ื• ืœื—ืฉื‘ ืืช ื›ืžื•ืช ื”ื˜ื™ืคื™ื ืžื—ื‘ืจื” ืฉืžื—ืœื™ื˜ื” ืœื‘ืœื•ืช ื‘ืžืกืขื“ื” ืื• ื‘ื™ืช ืงืคื”. ื›ืžื•ื‘ืŸ ืฉืœื ืชืžื™ื“ ื›ื•ืœื ืžืฉืื™ืจื™ื ื˜ื™ืค ืœืžืœืฆืจื™ื, ื–ื• ื™ื•ืชืจ ืžืกื•ืจืช ืžืขืจื‘ื™ืช, ืื‘ืœ ื”ืชื”ืœื™ืš ืฉืœ ืคื™ืชื•ื— ืืคืœื™ืงืฆื™ื” ื›ื–ื• ืžืขื ื™ื™ืŸ ื‘ื›ืœ ืžืงืจื”.

ืื ื• ืžื–ื›ื™ืจื™ื: ืœื›ืœ ืงื•ืจืื™ Habr - ื”ื ื—ื” ืฉืœ 10 ืจื•ื‘ืœ ื‘ืขืช ื”ืจืฉืžื” ืœื›ืœ ืงื•ืจืก Skillbox ื‘ืืžืฆืขื•ืช ืงื•ื“ ื”ื”ื˜ื‘ื” ืฉืœ Habr.

Skillbox ืžืžืœื™ืฆื”: ืงื•ืจืก ืžืขืฉื™ "ืžืคืชื— ืกืœื•ืœืจื™ PRO.

ื›ืš ื ืจืื™ืช ื”ืืคืœื™ืงืฆื™ื” ื‘ืคืขื•ืœื”:

ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?

ืžื›ื ื™ืกื™ื ืืช ื”ืื—ื•ื– ื”ืจืฆื•ื™ ืžื”ืกื›ื•ื ื”ื›ื•ืœืœ, ืืช ืžืกืคืจ ื”ืžืฉืชืชืคื™ื ื‘ืžืคื’ืฉ ื•ืžืงื‘ืœื™ื ืืช ื”ืชื•ืฆืื” - ื›ืžื•ืช ื”ื˜ื™ืค ืฉื›ื“ืื™ ืœื”ืฉืื™ืจ.

ืชื—ื™ืœืช ื”ืขื‘ื•ื“ื”

ืžืžืฉืง ื”ื™ื™ืฉื•ื ื”ืžืœื ื ืจืื” ื›ืš:
ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?

ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?

ืคืขื•ืœื” ืจืืฉื•ื ื” - ื”ื•ืจื“ืช ื‘ืกื™ืก ื”ืคืจื•ื™ืงื˜. ืคืชื— ืื•ืชื• ื‘-Android Studio 3.0 ื•ืื™ืœืš. ืื ื—ื ื• ื‘ื•ื ื™ื ื•ืžืฉื™ืงื™ื ืืช ื”ืคืจื•ื™ืงื˜ ื•ืจื•ืื™ื ืžืกืš ืœื‘ืŸ. ื”ื›ืœ ื‘ืกื“ืจ, ื›ื›ื” ื–ื” ืฆืจื™ืš ืœื”ื™ื•ืช.

ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?

ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?

ืคืขื•ืœื•ืช ื”ืžืฉืชืžืฉ ื ื›ืชื‘ื•ืช ื‘ืคืจื•ื™ืงื˜ ื‘ืกื“ืจ ื›ืจื•ื ื•ืœื•ื’ื™ ื›ื“ื™ ืœื”ื‘ื”ื™ืจ ื”ื›ืœ. ื›ื“ื™ ืœืฆืคื•ืช ื‘ื•, ืคืชื— ืืช View -> Tool Windows -> TODO.

ืื ื• ืœื•ืžื“ื™ื ืืช ื”ืคืจื•ื™ืงื˜ ื•ืคื•ืชื—ื™ื ืืช colors.xml ื›ื“ื™ ืœื”ืขืจื™ืš ืืช ืœื•ื— ื”ืฆื‘ืขื™ื. strings.xml ืžื›ื™ืœ ื ืชื•ื ื™ ื˜ืงืกื˜ (ื—ืชื™ืžื•ืช), ื•-styles.xml ืžื›ื™ืœ ืžืกืคืจ ืชื‘ื ื™ื•ืช ื’ื•ืคื ื™ื.

ืคื™ืชื•ื— ืžื“ื•ืจ ืขืœื•ืช

ืคืชื— ืืช activity_main.xml ื•ื”ื•ืกืฃ ืืช ื”ืงื•ื“ ืœืžื˜ื” ืœ-LinearLayout (#1):

<TextView
    android_id="@+id/expensePerPersonTextView"
    android_layout_width="match_parent"
    android_layout_height="wrap_content"
    android_paddingTop="30dp"
    style="@style/h1Bold"
    android_textColor="@color/colorAccent"
    android_text="0"/>
 
<TextView
    android_layout_width="match_parent"
    android_layout_height="wrap_content"
    android_paddingBottom="25dp"
    style="@style/h2"
    android_textColor="@color/colorAccent"
    android_text="@string/perPersonStaticText"/>

ืขื›ืฉื™ื• ืืชื” ื™ื›ื•ืœ ืœืกื’ื ืŸ ืืช ืกืคืจื™ื™ืช ื”ืขืจื›ื™ื ืื• ืœืฉื—ืง ืขื ืฆื‘ืขื™ื ื‘ืืžืฆืขื•ืช ื›ืœื™ material.io.

ื›ืขืช ื”ืคืจื•ื™ืงื˜ ื ืจืื” ื›ืš:

ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?
ื›ืคื™ ืฉืืชื” ื™ื›ื•ืœ ืœืจืื•ืช, ื”ืขืœื•ื™ื•ืช ืžื—ื•ืฉื‘ื•ืช ืขืœ ืกืžืš ื”ื ืชื•ื ื™ื ืฉื”ื–ื™ืŸ ื”ืžืฉืชืžืฉ.

ืคื™ืชื•ื— ืžื“ื•ืจ ื”ื—ืฉื‘ื•ื ื•ืช

ื”ื•ืกืฃ ืืช ื”ืงื•ื“ ืœืžื˜ื” ืœ-LinearLayout ืœืื—ืจ ืกืขื™ืฃ ื”ื”ื•ืฆืื•ืช (#2):

<LinearLayout
    android_layout_width="match_parent"
    android_layout_height="match_parent"
    android_orientation="vertical"
    android_background="@color/colorAccent">
 
<! โ€” TODO #3: Build Bill Section โ†’
 
โ€ฆ 
</LinearLayout>

ืื ื• ืกื•ื’ืจื™ื ืืช ื”-LinearLayout ืœืื—ืจ ืจืฉื™ืžืช ื”-TODOs, ื•ืœืื—ืจ ืžื›ืŸ ืžื•ืกื™ืคื™ื ืงื•ื“ ื—ื“ืฉ, ื•ืžืžืงืžื™ื ืื•ืชื• ื‘ืชื•ืš ื”-LinearLayout (#3):

<TextView
      android_layout_margin="15dp"
      android_layout_width="match_parent"
      android_layout_height="wrap_content"
      android_textColor="@color/colorWhite"
      style="@style/h4"
      android_text="@string/billStaticText"/>
 
<EditText
      android_id="@+id/billEditText"
      android_layout_width="match_parent"
      android_layout_height="wrap_content"
      android_textColor="@color/colorWhite"
      android_inputType="numberDecimal"
      android_maxLines="1"
      style="@style/h2Bold"
      android_text="0"/>

ืžื›ื™ื•ื•ืŸ ืฉื”ืžืฉื™ืžื” ื”ืขื™ืงืจื™ืช ืฉืœ ื”ืืคืœื™ืงืฆื™ื” ื”ื™ื ืœื—ืฉื‘ ืขืœื•ื™ื•ืช ืื™ืฉื™ื•ืช ืขื‘ื•ืจ ื›ืœ ืžืฉืชืชืฃ ื‘ืžืคื’ืฉ ืžืกืขื“ื”, costPerPersonTextView ืžืžืœืืช ืืช ื”ืชืคืงื™ื“ ื”ืขื™ืงืจื™.

EditText ืžื’ื‘ื™ืœ ืืช ื”ืงืœื˜ ืœืฉื•ืจื” ืื—ืช, ืคืจืžื˜ืจ ื–ื” ื—ื™ื™ื‘ ืœื”ื™ื•ืช ืžื•ื’ื“ืจ ืœ- NumberDecimal inputType.

ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?
ืื ื• ืžืฉื™ืงื™ื ืืช ื”ืคืจื•ื™ืงื˜ ืœื‘ื“ื™ืงื” ื•ืžื›ื ื™ืกื™ื ืืช ื”ืคืจืžื˜ืจื™ื ืœื ื–ืง ื›ืœืœื™ (ื›ื•ืกื•ืช, ืฆืœื—ื•ืช ืฉื‘ื•ืจื•ืช ื•ื›ื•')

ืคื™ืชื•ื— ืžื“ื•ืจ "ืื ืฉื™ื ื•ื˜ื™ืคื™ื".

ื›ื“ื™ ืœื”ื•ืกื™ืฃ ื‘ื—ื™ืจืช ื ืคื— ื˜ื™ืค, ื”ื“ื‘ืง ืืช ื”ืงื•ื“ ืœืžื˜ื” ื‘ืงื˜ืข LinearLayout ื”ื—ื“ืฉ (#4):

<TextView
      android_layout_margin="15dp"
      android_layout_width="match_parent"
      android_layout_height="wrap_content"
      android_textColor="@color/colorWhite"
      style="@style/h4"
      android_text="@string/tipStaticText"/>
 
<LinearLayout
      android_layout_width="match_parent"
      android_layout_height="wrap_content"
      android_orientation="horizontal">
 
<ImageButton
        android_id="@+id/subtractTipButton"
        style="@style/operationButton"
        android_layout_marginLeft="20dp"
        android_layout_marginStart="20dp"
        android_src="@drawable/subtract"/>
 
<TextView
        android_id="@+id/tipTextView"
        android_layout_margin="15dp"
        android_layout_width="0dp"
        android_layout_height="wrap_content"
        android_textColor="@color/colorWhite"
        android_layout_weight="1"
        style="@style/h2Bold"
        android_text="20%"/>
 
<ImageButton
        android_id="@+id/addTipButton"
        style="@style/operationButton"
        android_layout_marginEnd="20dp"
        android_layout_marginRight="20dp"
        android_src="@drawable/add"/>
 
</LinearLayout>

ื—ืœืง ื–ื” ืฉืœ ื”ืงื•ื“ ื”ื›ืจื—ื™ ื›ื“ื™ ืœื—ืฉื‘ ื‘ืžื“ื•ื™ืง ืืช ืกื›ื•ื ื”ื˜ื™ืค. ืขืจืš ื”ื˜ืงืกื˜ ื”ืžื•ื’ื“ืจ ื›ื‘ืจื™ืจืช ืžื—ื“ืœ ื”ื•ื 20. ืœื—ืฆื ื™ Image ืžืกื•ืคืงื™ื ืขื ืกืžืœื™ื ื‘ืชื™ืงื™ื™ื” ืขื ื”ืจืฉืื•ืช ื›ืชื™ื‘ื”.

ื”ืขืชืง ืืช ื”ืงื˜ืข ืœื—ืœื•ื˜ื™ืŸ ื•ื”ื•ืกืฃ ืืช ื”ื“ื‘ืจื™ื ื”ื‘ืื™ื (#5):

  • ืžื–ื”ื™ ImageButton (ื”ืคื—ืชืชPeopleButton, addPeopleButton)
  • TextView ids(numberOfPeopleStaticText, numberOfPeopleTextView)
  • DefaultText ืขื‘ื•ืจ numberOfPeopleTextView (ื—ื™ื™ื‘ ืœื”ื™ื•ืช 4).

ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?

ื›ืขืช, ื›ืืฉืจ ืืชื” ืžืคืขื™ืœ ืืช ื”ืืคืœื™ืงืฆื™ื”, ื™ืฉ ื”ื–ื“ืžื ื•ืช ืœื”ื•ืกื™ืฃ ืืช ืกื›ื•ื ื”ื—ืฉื‘ื•ื ื™ืช, ื’ื ื›ืคืชื•ืจื™ "ื”ื•ืกืฃ/ื—ื™ืกื•ืจ" ืคื•ืขืœื™ื, ืืš ืขื“ื™ื™ืŸ ืœื ืงืจื” ื›ืœื•ื.

ื”ื•ืกืคืช ืชืฆื•ื’ื•ืช

ืคืชื— ืืช MainActivity.kt ื•ื”ื•ืกืฃ ืืช ื–ื” ืœืคื•ื ืงืฆื™ื” initViews (#6):

private fun initViews() {
        expensePerPersonTextView = findViewById(R.id.expensePerPersonTextView)
        billEditText = findViewById(R.id.billEditText)
 
addTipButton = findViewById(R.id.addTipButton)
        tipTextView = findViewById(R.id.tipTextView)
        subtractTipButton = findViewById(R.id.subtractTipButton)
 
addPeopleButton = findViewById(R.id.addPeopleButton)
        numberOfPeopleTextView = findViewById(R.id.numberOfPeopleTextView)
        subtractPeopleButton = findViewById(R.id.subtractPeopleButton)
 
//TODO #8: Bind Buttons to Listener
 
//TODO #16: Bind EditText to TextWatcher
 
}

ืžืกื™ื™ื ืืช ื”ื›ืคืชื•ืจื™ื

ื›ื“ื™ ืœื”ื•ืกื™ืฃ ืชืžื™ื›ื” ื‘ืœื—ื™ืฆื•ืช ื›ืคืชื•ืจื™ื, ืื ื• ืžื™ื™ืฉืžื™ื ืืช View.OnClickListener ื‘ืจืžืช ื”ื›ื™ืชื” (#7):

class MainActivity: AppCompatActivity(), View.OnClickListener {

ืœื ื ื™ืชืŸ ื™ื”ื™ื” ืœื”ืจื›ื™ื‘ ืืช ื”ืคืจื•ื™ืงื˜ ื›ืขืช; ืขืœื™ืš ืœื‘ืฆืข ืžืกืคืจ ืฉืœื‘ื™ื ื ื•ืกืคื™ื (#8):

override fun onClick(v: View?) {
        when (v?.id) {
            R.id.addTipButton -> incrementTip()
            R.id.subtractTipButton -> decrementTip()
            R.id.addPeopleButton -> incrementPeople()
            R.id.subtractPeopleButton -> decrementPeople()
        }
    }

ืžื‘ื—ื™ื ืช ื›ืคืชื•ืจื™ื ื•ืžืชื’ื™ื, ืงื•ื˜ืœื™ืŸ ืžืืจื’ืŸ ื”ื›ืœ ืžืื•ื“ ืžื’ื ื™ื‘! ื”ื•ืกืฃ ืืช ื”ืงื•ื“ ืœืžื˜ื” ืœื›ืœ ืคื•ื ืงืฆื™ื•ืช ื”ื”ื’ื“ืœื” ื•ื”ื”ืคื—ืชื”
(ืžืก' 9 - ืžืก' 12):

private fun incrementTip() {
        if (tipPercent != MAX_TIP) {
            tipPercent += TIP_INCREMENT_PERCENT
            tipTextView.text = String.format("%d%%", tipPercent)
        }
    }
 
private fun decrementTip() {
        if (tipPercent != MIN_TIP) {
            tipPercent -= TIP_INCREMENT_PERCENT
            tipTextView.text = String.format("%d%%", tipPercent)
        }
    }
 
private fun incrementPeople() {
        if (numberOfPeople != MAX_PEOPLE) {
            numberOfPeople += PEOPLE_INCREMENT_VALUE
            numberOfPeopleTextView.text = numberOfPeople.toString()
        }
    }
 
private fun decrementPeople() {
        if (numberOfPeople != MIN_PEOPLE) {
            numberOfPeople -= PEOPLE_INCREMENT_VALUE
            numberOfPeopleTextView.text = numberOfPeople.toString()
        }
    }

ื›ืืŸ ื”ืงื•ื“ ืžื’ืŸ ืขืœ ืคื•ื ืงืฆื™ื•ืช ื”ื”ื’ื“ืœื” ืขื ืขืจื›ื™ื ืžืงืกื™ืžืœื™ื™ื (MAX_TIP & MAX_PEOPLE). ื‘ื ื•ืกืฃ, ื”ืงื•ื“ ืžื’ืŸ ืขืœ ืคื•ื ืงืฆื™ื•ืช ื”ื”ืคื—ืชื” ืขื ืขืจื›ื™ ืžื™ื ื™ืžื•ื (MIN_TIP & MIN_PEOPLE).

ื›ืขืช ืื ื• ืžืงืฉืจื™ื ืืช ื”ื›ืคืชื•ืจื™ื ืœืžืื–ื™ื ื™ื ื‘ืคื•ื ืงืฆื™ื™ืช initViews (#13):

private fun initViews() {
 
...
 
addTipButton.setOnClickListener(this)
        subtractTipButton.setOnClickListener(this)
 
addPeopleButton.setOnClickListener(this)
        subtractPeopleButton.setOnClickListener(this)
 
//TODO #15: Bind EditText to TextWatcher
}

ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?

ื›ืขืช ืชื•ื›ืœ ืœื”ื•ืกื™ืฃ ื ื–ืงื™ื ื”ื›ื•ืœืœื™ื, ื˜ื™ืคื™ื ื•ืžืกืคืจ ืžืฉืชืชืคื™ ื”ืคื’ื™ืฉื”. ื•ื‘ื›ืŸ, ืขื›ืฉื™ื• ื”ื“ื‘ืจ ื”ื›ื™ ื—ืฉื•ื‘...

ืกืขื™ืฃ ื—ื™ืฉื•ื‘ ืขืœื•ื™ื•ืช

ืงื•ื“ ื–ื” ืžื—ืฉื‘ ืขืœื•ื™ื•ืช (#14):

private fun calculateExpense() {
 
val totalBill = billEditText.text.toString().toDouble()
 
val totalExpense = ((HUNDRED_PERCENT + tipPercent) / HUNDRED_PERCENT) * totalBill
        val individualExpense = totalExpense / numberOfPeople
 
expensePerPersonTextView.text = String.format("$%.2f", individualExpense)
 
}

ื•ื‘ื›ืŸ, ื›ืืŸ ื ืงืจืืช ืคื•ื ืงืฆื™ื” ืฉืžืืคืฉืจืช ืœืงื—ืช ื‘ื—ืฉื‘ื•ืŸ ืืช ืžืกืคืจ ื”ืื ืฉื™ื ื‘ื—ื‘ืจื” ื•ืœื—ืฉื‘ ื˜ื™ืคื™ื (#15):

private fun incrementTip() {
 
โ€ฆ
 
}
 
private fun decrementTip() {
 
โ€ฆ
 
}
 
private fun incrementPeople() {
 
โ€ฆ
 
}
 
private fun decrementPeople() {
 
โ€ฆ
 
}

ื‘ื•ืื• ื ืคืขื™ืœ ืืช ื”ืืคืœื™ืงืฆื™ื”. ื–ื” ื ืจืื” ื•ืขื•ื‘ื“ ื ื”ื“ืจ. ืื‘ืœ ื–ื” ื™ื›ื•ืœ ืœื”ื™ื•ืช ื˜ื•ื‘ ื™ื•ืชืจ.

ืื ืชื ืกื” ืœื”ืกื™ืจ ืืช ืกื›ื•ื ื”ื—ืฉื‘ื•ืŸ ื•ืœืื—ืจ ืžื›ืŸ ืœื”ื’ื“ื™ืœ ืืช ืžืกืคืจ ื”ื˜ื™ืคื™ื ืื• ื”ื—ื‘ืจื™ื, ื”ืืคืœื™ืงืฆื™ื” ืชืงืจื•ืก ื›ื™ ืื™ืŸ ืขื“ื™ื™ืŸ ื‘ื“ื™ืงื” ืœื’ื‘ื™ ืขืจืš ื”ืขืœื•ืช ื”ืืคืก. ื™ืชืจื” ืžื›ืš, ืื ืชื ืกื” ืœืฉื ื•ืช ืืช ืกื›ื•ื ื”ื—ืฉื‘ื•ืŸ, ื”ื—ื™ื•ื‘ื™ื ืœื ื™ืขื•ื“ื›ื ื•.

ืฉืœื‘ื™ื ืื—ืจื•ื ื™ื

ื”ื•ืกืฃ TextWatcher (#16):

class MainActivity: AppCompatActivity(), View.OnClickListener, TextWatcher {

ืœืื—ืจ ืžื›ืŸ ืื ื• ืžื˜ืžื™ืขื™ื ืืช ืžืื–ื™ืŸ billEditText (#17):

billEditText.addTextChangedListener(ื–ื”)

ื‘ื ื•ืกืฃ, ืื ื• ืžื•ืกื™ืคื™ื ืงื•ื“ ืœื”ืคืขืœืช TextWatcher (#18):

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
        if (!billEditText.text.isEmpty()) {
            calculateExpense()
        }
    }
override fun afterTextChanged(s: Editable?) {}

    override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}

ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?

ื•ื‘ื›ืŸ, ืขื›ืฉื™ื• ืœื’ืžืจื™ ื”ื›ืœ ืขื•ื‘ื“! ืžื–ืœ ื˜ื•ื‘, ื›ืชื‘ืช "ืžื—ืฉื‘ื•ืŸ ืขืฆื•ืช" ืžืฉืœืš ื‘ืงื•ื˜ืœื™ืŸ.

ื™ืฆื™ืจืช ืžื—ืฉื‘ื•ืŸ ื˜ื™ืคื™ื ื‘ืงื•ื˜ืœื™ืŸ: ืื™ืš ื–ื” ืขื•ื‘ื“?

Skillbox ืžืžืœื™ืฆื”:

ืžืงื•ืจ: www.habr.com

ื”ื•ืกืคืช ืชื’ื•ื‘ื”