Commit efc2d1fa by Paktalin

Now a word can be deleted from WordItemInfoActivity

parent ddbdaae8
package com.paktalin.vocabularynotebook.activities package com.paktalin.vocabularynotebook.activities
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import android.view.Menu import android.view.Menu
import android.view.MenuItem
import com.paktalin.vocabularynotebook.R import com.paktalin.vocabularynotebook.R
import com.paktalin.vocabularynotebook.WordItem import com.paktalin.vocabularynotebook.WordItem
import kotlinx.android.synthetic.main.activity_word_info.* import kotlinx.android.synthetic.main.activity_word_info.*
...@@ -24,10 +26,28 @@ class WordItemInfoActivity: AppCompatActivity() { ...@@ -24,10 +26,28 @@ class WordItemInfoActivity: AppCompatActivity() {
return true return true
} }
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
when (item!!.itemId) {
R.id.item_delete -> {
wordItem.delete()
cancel()
}
R.id.item_edit -> {
}
}
return true
}
private fun setData() { private fun setData() {
tvWord.text = wordItem.pojo!!.word tvWord.text = wordItem.pojo!!.word
tvTranslation.text = wordItem.pojo!!.translation tvTranslation.text = wordItem.pojo!!.translation
} }
private fun cancel() {
val intentMainActivity = Intent(this, MainActivity::class.java)
startActivity(intentMainActivity)
}
companion object { private val TAG = "VN/" + WordItemInfoActivity::class.java.simpleName } companion object { private val TAG = "VN/" + WordItemInfoActivity::class.java.simpleName }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment