我的导航抽屉在Android中非常抢手(慢)

时间:2018-08-18 10:59:33

标签: android kotlin navigation-drawer

我在我的应用中创建导航抽屉。我在应用程序中放入了3个菜单项。我在这3个不同的菜单项中称为“活动”。当我单击项目时,它的动作非常抢(慢)。这是我的代码:-

override fun onNavigationItemSelected(item: MenuItem): Boolean {

    selectedCategoryId = settingHandler.getSettings("default_category")
    val catHandler = CategoryHandler(this)
    val cat = catHandler.getCategoryWithId(selectedCategoryId.toInt())

    /**
     * Navigation drawer item click events
     * @author maulik
     */
    when (item.itemId) {
        R.id.navFormula -> {
            val intent = Intent(this, FormulaActivity::class.java)
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
            intent.putExtra("cat", cat)
            startActivity(intent)
        }
        R.id.navExam -> {
            val intent = Intent(this, PreExamActivity::class.java)
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
            intent.putExtra("cat_id", selectedCategoryId)
            //Common.selectedCategoryId = selectedCategoryId
            startActivity(intent)
        }
        R.id.navArticles -> {
            val intent = Intent(this, ArticlesAllActivity::class.java)
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
            startActivity(intent)
        }

    }

    drawer_layout.closeDrawer(GravityCompat.START)
    return true
}

0 个答案:

没有答案