本文整理汇总了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)
}
}
开发者ID:perrier1034,项目名称:Post-it-Note,代码行数:57,代码来源:BaseActivity.scala
示例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)
}
}
开发者ID:pamu,项目名称:firebase-scala-android,代码行数:24,代码来源:MainActivity.scala
示例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)
}
}
}
开发者ID:pamu,项目名称:happyheal,代码行数:48,代码来源:AddressActivity.scala
示例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)
}
}
开发者ID:pamu,项目名称:happyheal,代码行数:30,代码来源:OrdersActivity.scala
示例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"
}
开发者ID:pamu,项目名称:happyheal,代码行数:45,代码来源:WizardActivity.scala
注:本文中的android.support.v7.app.AppCompatActivity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论