本文整理汇总了Scala中android.support.v7.app.AppCompatActivity类的典型用法代码示例。如果您正苦于以下问题:Scala AppCompatActivity类的具体用法?Scala AppCompatActivity怎么用?Scala AppCompatActivity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AppCompatActivity类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: BaseActivity
//设置package包名称以及导入依赖的类
package com.android.perrier1034.post_it_note.ui
import android.graphics.drawable.ColorDrawable
import android.os.{Build, Bundle}
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
import android.view.{View, ViewGroup, WindowManager}
import com.android.perrier1034.post_it_note.{Constants, R}
abstract class BaseActivity extends AppCompatActivity {
lazy val mToolbar = findViewById(R.id.toolbar).asInstanceOf[Toolbar]
lazy val mStatusBar = findViewById(R.id.status_bar)
protected def contentsResId: Int
protected def init()
override final def onCreate(savedInstanceState: Bundle) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_base)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
getWindow.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
}
val container = findViewById(R.id.container).asInstanceOf[ViewGroup]
initToolbar(container)
View.inflate(this, contentsResId, container)
init()
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
getWindow.setBackgroundDrawable(new ColorDrawable(Constants.STATUS_BAR_COLOR_BASE))
}
def initToolbar(container: ViewGroup) = {
setSupportActionBar(mToolbar)
mToolbar.setBackgroundColor(Constants.TOOL_BAR_COLOR_BASE)
}
def getToolbar: Toolbar = mToolbar
def setStatusBarColorByPosition(_pos: Int) {
val pos: Int = if (_pos >= 0) _pos else 14
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow.setStatusBarColor(Constants.PAGER_COLOR_MAPPING(pos)(3))
}
else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
mStatusBar.setBackgroundColor(Constants.PAGER_COLOR_MAPPING(pos)(0))
}
}
def setActionModeStatusBarColorLOLLIPOP() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow.setStatusBarColor(Constants.STATUS_BAR_COLOR_ACTION_MODE)
}
}
示例2: MainActivity
//设置package包名称以及导入依赖的类
package com.rxbytes.scalaandroid.ui
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.rxbytes.scalaandroid.{TypedFindView, TR}
import macroid.Contexts
class MainActivity
extends AppCompatActivity
with Contexts[AppCompatActivity]
with TypedFindView {
val LOG_TAG = classOf[MainActivity].getSimpleName
override def onCreate(savedInstanceState: Bundle): Unit = {
super.onCreate(savedInstanceState)
setContentView(TR.layout.layout_main_activity.id)
val toolbar = findView(TR.toolbar)
setSupportActionBar(toolbar)
}
}
示例3: AddressActivity
//设置package包名称以及导入依赖的类
package com.happyheal.happyhealapp.ui.address
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.{MenuItem, Menu}
import com.happyheal.happyhealapp.{R, TR, TypedFindView}
import com.happyheal.happyhealapp.commons.ContextWrapperProvider
import com.happyheal.happyhealapp.modules.persistence.impl.PersistenceServicesComponentImpl
import macroid.{ContextWrapper, Contexts}
import macroid.FullDsl._
class AddressActivity
extends AppCompatActivity
with Contexts[AppCompatActivity]
with ContextWrapperProvider
with TypedFindView
with PersistenceServicesComponentImpl
with AddressComposer {
override lazy implicit val contextProvider: ContextWrapper = activityContextWrapper
override def onCreate(savedInstanceState: Bundle): Unit = {
super.onCreate(savedInstanceState)
setContentView(TR.layout.address_layout.id)
toolbar map setSupportActionBar
getSupportActionBar.setHomeButtonEnabled(true)
getSupportActionBar().setDisplayHomeAsUpEnabled(true)
getSupportActionBar().setDisplayShowHomeEnabled(true)
runUi(addPlaces(List("Silkboard", "Madiwala")))
}
override def onCreateOptionsMenu(menu: Menu): Boolean = {
getMenuInflater.inflate(R.menu.menu_address, menu)
true
}
override def onOptionsItemSelected(item: MenuItem): Boolean = {
item.getItemId match {
case R.id.tick =>
onSubmit()
return true
case _ => return super.onOptionsItemSelected(item)
}
}
}
示例4: OrdersActivity
//设置package包名称以及导入依赖的类
package com.happyheal.happyhealapp.ui.orders
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.happyheal.happyhealapp.{TypedFindView, TR}
import com.happyheal.happyhealapp.commons.ContextWrapperProvider
import macroid.{ContextWrapper, Contexts}
class OrdersActivity
extends AppCompatActivity
with Contexts[AppCompatActivity]
with ContextWrapperProvider
with TypedFindView
with OrdersComposer {
override implicit val contextProvider: ContextWrapper = activityContextWrapper
override def onCreate(savedInstanceState: Bundle): Unit = {
super.onCreate(savedInstanceState)
setContentView(TR.layout.orders_layout.id)
toolbar map setSupportActionBar
getSupportActionBar.setHomeButtonEnabled(true)
getSupportActionBar().setDisplayHomeAsUpEnabled(true)
getSupportActionBar().setDisplayShowHomeEnabled(true)
}
}
示例5: WizardActivity
//设置package包名称以及导入依赖的类
package com.happyheal.happyhealapp.ui.wizard
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import com.happyheal.happyhealapp.{TypedFindView, TR}
import com.happyheal.happyhealapp.commons.ContextWrapperProvider
import com.happyheal.happyhealapp.modules.persistence.impl.PersistenceServicesComponentImpl
import com.happyheal.happyhealapp.ui.main.MainActivity
import macroid.{ContextWrapper, Contexts}
import macroid.FullDsl._
class WizardActivity
extends AppCompatActivity
with Contexts[AppCompatActivity]
with ContextWrapperProvider
with PersistenceServicesComponentImpl
with TypedFindView
with WizardComposer {
override implicit lazy val contextProvider: ContextWrapper = activityContextWrapper
val LOG_TAG = classOf[WizardActivity].getSimpleName
override def onCreate(savedInstanceState: Bundle): Unit = {
super.onCreate(savedInstanceState)
Log.d(LOG_TAG, "WizardActivity")
val extras = getIntent.getExtras
val tutorialMode = if (extras != null) extras.getBoolean(WizardActivity.tutorialMode, false) else false
if (!(tutorialMode || !persistenceServices.isWizardSeen)) {
finish()
startActivity(new Intent(getApplication, classOf[MainActivity]))
}
setContentView(TR.layout.wizard_layout.id)
runUi(initializeWizard(tutorialMode))
}
}
object WizardActivity {
val tutorialMode = "tutorial_mode"
}