• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala Bundle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中android.os.Bundle的典型用法代码示例。如果您正苦于以下问题:Scala Bundle类的具体用法?Scala Bundle怎么用?Scala Bundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Bundle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: MainActivity

//设置package包名称以及导入依赖的类
package $package$.activity


import $package$.api.UiService
import $package$.model.Ticker
import android.content.{Intent, Context}
import android.view.View
import android.widget.{TextView, ProgressBar, LinearLayout}
import macroid.FullDsl._
import macroid._
import android.app.Activity
import android.os.Bundle

class MainActivity extends Activity with Contexts[Activity] with MainActivityView with UiService {

  override def onCreate(b: Bundle): Unit = {
    super.onCreate(b)
    setTitle("Hello world, $name$!")
    setContentView(ui.get)
    update
  }

  def update = api(_.pubticker("btcusd")) mapUi updateView

  def updateView(t: Ticker) = runUi(
    lastPriceSlot <~ text("Whoa! Bitcoin price is " + t.last_price)
  )
}

trait MainActivityView {
  var lastPriceSlot = slot[TextView]

  def ui(implicit context: ActivityContext): Ui[LinearLayout] = {
    l[LinearLayout](
      w[TextView] <~ wire(lastPriceSlot)
    )
  }

} 
开发者ID:aafa,项目名称:rest-android-scala.g8,代码行数:40,代码来源:MainActivity.scala


示例2: getExecutable

//设置package包名称以及导入依赖的类
package com.github.shadowsocks.plugin

import android.content.{ContentProvider, ContentValues}
import android.database.{Cursor, MatrixCursor}
import android.net.Uri
import android.os.{Bundle, ParcelFileDescriptor}


  def getExecutable: String = throw new UnsupportedOperationException

  def openFile(uri: Uri): ParcelFileDescriptor
  override def openFile(uri: Uri, mode: String): ParcelFileDescriptor = {
    assert(mode == "r")
    openFile(uri)
  }

  override def call(method: String, arg: String, extras: Bundle): Bundle = method match {
    case PluginContract.METHOD_GET_EXECUTABLE =>
      val out = new Bundle()
      out.putString(PluginContract.EXTRA_ENTRY, getExecutable)
      out
    case _ => super.call(method, arg, extras)
  }

  // Methods that should not be used
  override def update(uri: Uri, values: ContentValues, selection: String, selectionArgs: Array[String]): Int = ???
  override def insert(uri: Uri, values: ContentValues): Uri = ???
  override def delete(uri: Uri, selection: String, selectionArgs: Array[String]): Int = ???
} 
开发者ID:likky,项目名称:shadowsocks_android_build,代码行数:30,代码来源:NativePluginProvider.scala


示例3: ResolvedPlugin

//设置package包名称以及导入依赖的类
package com.github.shadowsocks.plugin

import android.content.pm.{PackageManager, ResolveInfo}
import android.graphics.drawable.Drawable
import android.os.Bundle
import com.github.shadowsocks.ShadowsocksApplication.app


abstract class ResolvedPlugin(resolveInfo: ResolveInfo, packageManager: PackageManager = app.getPackageManager)
  extends Plugin {
  protected def metaData: Bundle

  override final lazy val id: String = metaData.getString(PluginContract.METADATA_KEY_ID)
  override final lazy val label: CharSequence = resolveInfo.loadLabel(packageManager)
  override final lazy val icon: Drawable = resolveInfo.loadIcon(packageManager)
  override final lazy val defaultConfig: String = metaData.getString(PluginContract.METADATA_KEY_DEFAULT_CONFIG)
  override def packageName: String = resolveInfo.resolvePackageName
  override final lazy val trusted: Boolean = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES)
    .signatures.exists(PluginManager.trustedSignatures.contains)
} 
开发者ID:likky,项目名称:shadowsocks_android_build,代码行数:21,代码来源:ResolvedPlugin.scala


示例4: Main

//设置package包名称以及导入依赖的类
package sword.langbook.android.activities

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.View
import sword.langbook.android.{R, TR}

class Main extends BaseActivity {
  override def onCreate(savedInstanceState: Bundle) = {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.main)

    findView(TR.checkLanguagesButton).setOnClickListener(new View.OnClickListener() {
      override def onClick(v: View): Unit = {
        LanguageSelector.openWith(Main.this, RequestCodes.pickLanguage)
      }
    })

    findView(TR.checkWordsButton).setOnClickListener(new View.OnClickListener() {
      override def onClick(v: View): Unit = Selector.openWith(Main.this, Selector.wordsAndBunches)
    })

    findView(TR.startQuizButton).setOnClickListener(new View.OnClickListener() {
      override def onClick(v: View): Unit = QuizSelector.openWith(Main.this)
    })

    findView(TR.settingsButton).setOnClickListener(new View.OnClickListener() {
      override def onClick(v: View): Unit = Settings.openWith(Main.this)
    })
  }

  override def onActivityResult(requestCode :Int, resultCode :Int, data :Intent) :Unit = {
    super.onActivityResult(requestCode, resultCode, data)

    if (requestCode == RequestCodes.pickLanguage && resultCode == Activity.RESULT_OK) {
      LanguageDetails.openWith(Main.this, languageEncodedKey = data.getStringExtra(BundleKeys.languageKey))
    }
  }
} 
开发者ID:carlos-sancho-ramirez,项目名称:android-scala-langbook,代码行数:41,代码来源:Main.scala


示例5: SymbolDetails

//设置package包名称以及导入依赖的类
package sword.langbook.android.activities

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import sword.langbook.android.{TR, R}
import sword.langbook.db.Symbol

object SymbolDetails {
  private val className = "sword.langbook.android.activities.SymbolDetails"

  def openWith(activity :Activity, symbol :Symbol, requestCode :Int = 0) = {
    val intent = new Intent()
    intent.setClassName(activity, className)
    intent.putExtra(BundleKeys.symbolKey, symbol.key.encoded)

    if (requestCode > 0) activity.startActivityForResult(intent, requestCode)
    else activity.startActivity(intent)
  }
}

class SymbolDetails extends BaseActivity {
  lazy val symbolKeyOption = linkedDb.storageManager.decode(getIntent.getStringExtra(BundleKeys.symbolKey))
  lazy val symbolOption = symbolKeyOption.map(Symbol(_))

  override def onCreate(savedInstanceState :Bundle) :Unit = {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.word_details)
    findView(TR.recyclerView).setLayoutManager(new LinearLayoutManager(this))
    updateUi()
  }

  def updateUi(): Unit = {
    val title = symbolOption.map(_.text).getOrElse("")
    val toolBar = findView(TR.toolBar)
    toolBar.setTitle(title)

    for (symbol <- symbolOption) {
      findView(TR.recyclerView).setAdapter(new SymbolDetailsAdapter(this, symbol))
    }
  }
} 
开发者ID:carlos-sancho-ramirez,项目名称:android-scala-langbook,代码行数:44,代码来源:SymbolDetails.scala


示例6: LanguageDetails

//设置package包名称以及导入依赖的类
package sword.langbook.android.activities

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import sword.langbook.android.{TR, R}
import sword.langbook.db.Language

object LanguageDetails {
  private val className = "sword.langbook.android.activities.LanguageDetails"

  def openWith(activity :Activity, requestCode :Int = 0, language: Language = null, languageEncodedKey: String = null) = {
    val intent = new Intent()
    intent.setClassName(activity, className)
    val languageEncoded = {
      if (language != null) language.key.encoded
      else languageEncodedKey
    }
    intent.putExtra(BundleKeys.languageKey, languageEncoded)

    if (requestCode > 0) activity.startActivityForResult(intent, requestCode)
    else activity.startActivity(intent)
  }
}

class LanguageDetails extends BaseActivity {

  lazy val languageKeyOption = linkedDb.storageManager.decode(getIntent.getStringExtra(BundleKeys.languageKey))
  lazy val languageOption = languageKeyOption.map(Language(_))

  override def onCreate(savedInstanceState :Bundle) :Unit = {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.word_details)

    val toolBar = findView(TR.toolBar)
    val recyclerView = findView(TR.recyclerView)
    for (language <- languageOption) {
      for (title <- language.suitableTextForLanguage(preferredLanguage)) {
        toolBar.setTitle(title)
      }

      val wordCount = language.wordCount
      val statistics = Vector(("Number of words", wordCount.toString))
      recyclerView.setLayoutManager(new LinearLayoutManager(this))
      recyclerView.setAdapter(new LanguageDetailsAdapter(this, preferredLanguage, "", language.alphabets.toVector, statistics))
    }
  }
} 
开发者ID:carlos-sancho-ramirez,项目名称:android-scala-langbook,代码行数:50,代码来源:LanguageDetails.scala


示例7: AlphabetDetails

//设置package包名称以及导入依赖的类
package sword.langbook.android.activities

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.support.v7.widget.{GridLayoutManager, LinearLayoutManager}
import sword.langbook.android.{TR, R}
import sword.langbook.db.Alphabet

object AlphabetDetails {
  private val className = "sword.langbook.android.activities.AlphabetDetails"

  def openWith(activity :Activity, requestCode :Int = 0, alphabetEncodedKey: String = null) = {
    val intent = new Intent()
    intent.setClassName(activity, className)
    intent.putExtra(BundleKeys.alphabetKey, alphabetEncodedKey)

    if (requestCode > 0) activity.startActivityForResult(intent, requestCode)
    else activity.startActivity(intent)
  }
}

class AlphabetDetails extends BaseActivity {

  lazy val alphabetKeyOption = linkedDb.storageManager.decode(getIntent.getStringExtra(BundleKeys.alphabetKey))
  lazy val alphabetOption = alphabetKeyOption.map(Alphabet(_))

  override def onCreate(savedInstanceState :Bundle) :Unit = {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.word_details)

    val toolBar = findView(TR.toolBar)
    val recyclerView = findView(TR.recyclerView)
    for (alphabet <- alphabetOption) {
      for (title <- alphabet.suitableTextForLanguage(preferredLanguage)) {
        toolBar.setTitle(title)
      }

      val adapter = AlphabetDetailsAdapter(this, alphabet)
      recyclerView.setLayoutManager(new GridLayoutManager(this, adapter.spanCount))
      recyclerView.setAdapter(adapter)
    }
  }
} 
开发者ID:carlos-sancho-ramirez,项目名称:android-scala-langbook,代码行数:45,代码来源:AlphabetDetails.scala


示例8: onActivityCreated

//设置package包名称以及导入依赖的类
package com.mishiranu.instantimage.ui

import android.app.Fragment
import android.os.Bundle

import rx.lang.scala.Subscription

trait RxFragment extends Fragment {
  private var subscription: Subscription = _

  override def onActivityCreated(savedInstanceState: Bundle): Unit = {
    super.onActivityCreated(savedInstanceState)
    subscription = createRxSubscription
  }

  override def onDestroy(): Unit = {
    super.onDestroy()
    unsubscribe()
  }

  private def unsubscribe(): Unit = {
    if (subscription != null) {
      subscription.unsubscribe()
      subscription = null
    }
  }

  private var resumed = false
  private var queuedResult: () => Unit = _

  override def onResume(): Unit = {
    super.onResume()
    resumed = true
    if (queuedResult != null) {
      val result = queuedResult
      queuedResult = null
      handleRxResult(result())
    }
  }

  override def onPause(): Unit = {
    super.onPause()
    resumed = false
  }

  protected def handleRxResult(result: => Unit): Unit = {
    unsubscribe()
    if (resumed) {
      result
    } else {
      queuedResult = () => result
    }
  }

  protected def createRxSubscription: Subscription
} 
开发者ID:Mishiranu,项目名称:Instant-Image,代码行数:57,代码来源:RxFragment.scala


示例9: PreferenceFragment

//设置package包名称以及导入依赖的类
package be.mygod.preference

import android.app.DialogFragment
import android.os.Bundle
import android.support.v14.preference.{PreferenceFragment => Base}
import android.support.v7.preference.PreferenceScreen
import android.view.{LayoutInflater, ViewGroup}

abstract class PreferenceFragment extends Base {
  override def onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle) =
    super.onCreateView(inflater, container, savedInstanceState)

  protected final def displayPreferenceDialog(key: String, fragment: DialogFragment) {
    val bundle = new Bundle(1)
    bundle.putString("key", key)
    fragment.setArguments(bundle)
    fragment.setTargetFragment(this, 0)
    getFragmentManager.beginTransaction()
      .add(fragment, "android.support.v14.preference.PreferenceFragment.DIALOG")
      .commitAllowingStateLoss()
  }

  override protected def onCreateAdapter(screen: PreferenceScreen) = new PreferenceGroupAdapter(screen)

  override def onResume {
    super.onResume
    getListView.scrollBy(0, 0)
  }
} 
开发者ID:RoomArchitect,项目名称:test0000,代码行数:30,代码来源:PreferenceFragment.scala


示例10: QuickToggleShortcut

//设置package包名称以及导入依赖的类
package com.github.shadowsocks

import android.app.Activity
import android.content.Intent
import android.content.pm.ShortcutManager
import android.os.{Build, Bundle}
import com.github.shadowsocks.utils.{State, Utils}


class QuickToggleShortcut extends Activity with ServiceBoundContext {
  override def onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)
    getIntent.getAction match {
      case Intent.ACTION_CREATE_SHORTCUT =>
        setResult(Activity.RESULT_OK, new Intent()
          .putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(this, classOf[QuickToggleShortcut]))
          .putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.quick_toggle))
          .putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
            Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher)))
        finish()
      case _ =>
        attachService()
        if (Build.VERSION.SDK_INT >= 25) getSystemService(classOf[ShortcutManager]).reportShortcutUsed("toggle")
    }
  }

  override def onDestroy() {
    detachService()
    super.onDestroy()
  }

  override def onServiceConnected() {
    bgService.getState match {
      case State.STOPPED => Utils.startSsService(this)
      case State.CONNECTED => Utils.stopSsService(this)
      case _ => // ignore
    }
    finish()
  }
} 
开发者ID:wfjsw,项目名称:shadowsocksr-android-with-patches,代码行数:41,代码来源:QuickToggleShortcut.scala


示例11: 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


示例12: ConfirmDialog

//设置package包名称以及导入依赖的类
package com.android.perrier1034.post_it_note.ui.dialog

import java.io.Serializable

import android.app.{Dialog, DialogFragment}
import android.content.DialogInterface
import android.content.DialogInterface.OnClickListener
import android.os.Bundle
import android.support.v7.app.AlertDialog

object ConfirmDialog {

  def newInstance(title: Option[String], msg: String, iconResId: Option[Int], lis: ClickListener) = {
    val instance = new ConfirmDialog
    val bun = new Bundle
    bun.putString("msg", msg)
    bun.putSerializable("listener", lis)
    title foreach { bun.putString("title", _) }
    iconResId foreach { bun.putInt("icon", _)}
    instance.setArguments(bun)
    instance
  }

  trait ClickListener extends Serializable {
    def onClick()
  }

}

class ConfirmDialog extends DialogFragment {

  override def onCreateDialog(savedInstanceState: Bundle): Dialog = {

    val builder = new AlertDialog.Builder(getActivity)
      .setMessage(getArguments.getString("msg"))
      .setPositiveButton("OK", new OnClickListener {
      override def onClick(dialogInterface: DialogInterface, i: Int) =
        getArguments.getSerializable("listener").asInstanceOf[ConfirmDialog.ClickListener].onClick()
    })

    Option(getArguments.getString("title")) foreach { builder.setTitle(_) }
    val icon = getArguments.getInt("icon", 0)
    if (icon > 0) builder.setIcon(icon)

    builder.create
  }
} 
开发者ID:perrier1034,项目名称:Post-it-Note,代码行数:48,代码来源:ConfirmDialog.scala


示例13: ViewerDialog

//设置package包名称以及导入依赖的类
package com.android.perrier1034.post_it_note.ui.dialog

import android.app.{Dialog, DialogFragment}
import android.graphics.Bitmap
import android.os.{Bundle, Parcelable}
import android.support.v4.view.PagerAdapter
import android.view.{View, ViewGroup}
import com.android.perrier1034.post_it_note.R
import com.android.perrier1034.post_it_note.ui.views.LockableViewPager
import uk.co.senab.photoview.PhotoView

object ViewerDialog {
  private val KEY_BMPS: String = "0"
  private val KEY_DEFAULT_POS: String = "1"

  def newInstance(bmps: Array[Bitmap], defaultPos: Int): ViewerDialog = {
    val instance = new ViewerDialog
    val bun = new Bundle
    bun.putParcelableArray(KEY_BMPS, bmps.asInstanceOf[Array[Parcelable]])
    bun.putInt(KEY_DEFAULT_POS, defaultPos)
    instance.setArguments(bun)
    instance
  }
}

class ViewerDialog extends DialogFragment {

  def getBmps: Array[Bitmap] =
    getArguments.getParcelableArray(ViewerDialog.KEY_BMPS).asInstanceOf[Array[Bitmap]]

  def getDefalutPosition: Int =
    getArguments.getInt(ViewerDialog.KEY_DEFAULT_POS)

  override def onCreateDialog(savedInstanceState: Bundle): Dialog = {
    val vg = getActivity.getLayoutInflater.inflate(R.layout.dialog_photo_viewer, null).asInstanceOf[ViewGroup]
    val viewPager = vg.findViewById(R.id.view_pager).asInstanceOf[LockableViewPager]
    viewPager.setAdapter(new PagerAdapter() {

      override def getCount: Int = getBmps.length

      override def instantiateItem(container: ViewGroup, position: Int): View = {
        val photoView = new PhotoView(container.getContext)
        photoView.setImageBitmap(getBmps(position))
        container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
        photoView
      }

      override def destroyItem(container: ViewGroup, position: Int, obj: AnyRef) =
        container.removeView(obj.asInstanceOf[View])

      override def isViewFromObject(view: View, obj: AnyRef): Boolean =
        view eq obj

    })
    val d = new Dialog(getActivity, R.style.TransparentDialog)
    d.setContentView(vg)
    viewPager.setCurrentItem(getDefalutPosition)
    d
  }
} 
开发者ID:perrier1034,项目名称:Post-it-Note,代码行数:61,代码来源:ViewerDialog.scala


示例14: ListDialog

//设置package包名称以及导入依赖的类
package com.android.perrier1034.post_it_note.ui.dialog

import android.app.AlertDialog.Builder
import android.app.Dialog
import android.os.Bundle
import android.support.v4.app.DialogFragment
import android.view.View
import android.widget.AdapterView.OnItemClickListener
import android.widget.{AdapterView, ArrayAdapter}

object ListDialog {
  def newInstance(title: Option[String], listItems: Seq[ListItem], icon: Option[Int]): DialogFragment = {
    val bun = new Bundle
    title foreach { bun.putString("title", _) }
    bun.putSerializable("items", listItems.toArray)
    icon foreach { bun.putInt("icon", _)}
    val instance = new ListDialog
    instance.setArguments(bun)
    instance
  }
}

class ListDialog extends DialogFragment  {

  override def onCreateDialog(savedInstanceState: Bundle): Dialog = {
    def createLabelArray: Array[String] = getListItems map { _.label }
    def getListItems = getArguments.getSerializable("items").asInstanceOf[Array[ListItem]]

    val adapter = new ArrayAdapter[String](getActivity, android.R.layout.simple_list_item_1, createLabelArray)
    val builder = new Builder(getActivity).setAdapter(adapter, null)

    val title = getArguments.getString("title", null)
    if (title != null) builder.setTitle(getArguments.getString("title"))

    val icon = getArguments.getInt("icon", 0)
    if (icon > 0) builder.setIcon(icon)
    val dialog = builder.create()

    val listView = dialog.getListView
    listView.setOnItemClickListener(new OnItemClickListener {
      override def onItemClick(adapterView: AdapterView[_], view: View, i: Int, l: Long): Unit = {
        getListItems(i).execute()
        dismiss()
      }
    })
    dialog
  }

} 
开发者ID:perrier1034,项目名称:Post-it-Note,代码行数:50,代码来源:ListDialog.scala


示例15: DatePickerDialog

//设置package包名称以及导入依赖的类
package com.android.perrier1034.post_it_note.ui.dialog

import android.os.Bundle
import android.support.v4.app.DialogFragment
import android.view.{ViewGroup, LayoutInflater, View}
import com.android.perrier1034.post_it_note.R
import com.prolificinteractive.materialcalendarview.{OnDateChangedListener, CalendarDay, MaterialCalendarView}

object DatePickerDialog {
  trait Listener extends Serializable {
    def call(y: Int, m: Int, d: Int)
  }
  def newInstance(listener: Listener) = {
    val instance = new DatePickerDialog
    val bun = new Bundle
    bun.putSerializable("listener", listener)
    instance.setArguments(bun)
    instance
  }
}

class DatePickerDialog extends DialogFragment with OnDateChangedListener {

  override def onCreateView(inflater: LayoutInflater, container: ViewGroup, state: Bundle) =
    inflater.inflate(R.layout.view_date_picker, container, false)

  override def onViewCreated(v: View, b: Bundle) {
    super.onViewCreated(v, b)

    val widget =  v.findViewById(R.id.calendarView).asInstanceOf[MaterialCalendarView]
    widget.setOnDateChangedListener(this)
  }

  override def onDateChanged(widget: MaterialCalendarView, date: CalendarDay) {
    getArguments.getSerializable("listener").asInstanceOf[DatePickerDialog.Listener]
    .call(date.getYear, date.getMonth, date.getDay)
    dismiss()
  }
} 
开发者ID:perrier1034,项目名称:Post-it-Note,代码行数:40,代码来源:DatePickerDialog.scala


示例16: MainActivity

//设置package包名称以及导入依赖的类
package net.ladstatt.android.sqlite

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.view.View.OnClickListener
import android.widget.Button


class MainActivity extends Activity {


  override protected def onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.main)
  }

  // called by a button click - see main.xml
  def gotoFirstActivity(view: View): Unit = {
    val i = new Intent(this, classOf[DbActivity])
    startActivity(i)
  }

} 
开发者ID:rladstaetter,项目名称:android-sqlite,代码行数:26,代码来源:MainActivity.scala


示例17: DbActivity

//设置package包名称以及导入依赖的类
package net.ladstatt.android.sqlite

import android.app.Activity
import android.content.{ContentValues, Context, Intent}
import android.database.Cursor
import android.database.sqlite.{SQLiteDatabase, SQLiteOpenHelper}
import android.os.Bundle
import android.text.Editable
import android.view.View
import android.widget.EditText

import scala.collection.JavaConversions._
import scala.util.Random



class DbActivity extends Activity {

  var aDb: SimpleDb = _

  override protected def onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.first)
    aDb = SimpleDb(getApplicationContext)
  }

  def saveToDb(view: View): Unit = {
    val firstName: String = findViewById(R.id.firstName).asInstanceOf[EditText].getText.toString
    val secondName: String = findViewById(R.id.secondName).asInstanceOf[EditText].getText.toString

    // I WANT TO WRITE TO THE DATABASE
    val person: Person = Person(firstName, secondName)

    val personDao = aDb.mkPersonDao()
    personDao.insert(person)
  }

  def loadFromDb(view: View): Unit = {
    val i = new Intent(this, classOf[MyListActivity])
    startActivity(i)

  }
} 
开发者ID:rladstaetter,项目名称:android-sqlite,代码行数:44,代码来源:DbActivity.scala


示例18: WebViewFragment

//设置package包名称以及导入依赖的类
package com.rallets

import android.os.Bundle
import android.view.{LayoutInflater, View, ViewGroup}
import android.webkit.WebView
import com.github.shadowsocks.{R, ToolbarFragment}

class WebViewFragment(titleId: Int, url: String) extends ToolbarFragment {
  override def onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle): View =
    inflater.inflate(R.layout.layout_webview, container, false)

  override def onViewCreated(view: View, savedInstanceState: Bundle) {
    super.onViewCreated(view, savedInstanceState)
    val title = getString(titleId)
    toolbar.setTitle(title)
    val web = view.findViewById(R.id.web_view).asInstanceOf[WebView]
    val settings = web.getSettings()
    settings.setJavaScriptEnabled(true)
    web.setWebViewClient(new RalletsWebClient(getActivity, title))
    web.loadUrl(url)
  }
} 
开发者ID:rallets-network,项目名称:rallets-android,代码行数:23,代码来源:WebViewFragment.scala


示例19: AddMeasurmentFragment

//设置package包名称以及导入依赖的类
package zvr.da

import android.app.Fragment
import android.os.Bundle
import android.view.{LayoutInflater, View, ViewGroup}

class AddMeasurmentFragment extends Fragment {
  override def onCreateView(inflator: LayoutInflater, container: ViewGroup, state: Bundle) : View = {
     inflator.inflate(R.layout.edit_measurement, container, false)
  }

}

object AddMeasurmentFragment {
  def apply() = {
    new AddMeasurmentFragment()
  }
} 
开发者ID:diabetic-assist,项目名称:da,代码行数:19,代码来源:AddMeasurmentFragment.scala


示例20: PreBattleActivity

//设置package包名称以及导入依赖的类
package com.github.fellowship_of_the_bus.bruteb

import models._

import org.scaloid.common._

import android.os.Bundle
import android.view.{Gravity, View}
import android.graphics.Color
import android.widget.GridView
import android.content.{Intent, Context}
import android.graphics.Canvas

import java.util.concurrent.atomic.AtomicInteger

import scala.language.postfixOps

class PreBattleActivity extends BaseActivity {
  import Game.game
  var startButton: SButton = null


  override def onCreate(savedState: Bundle): Unit = {
    android.util.Log.e("bruteb", "Brute Blitzkrieg pre battle activity started")
    super.onCreate(savedState)

    setContentView(
      new SRelativeLayout{
        new SLinearLayout {
          (new BattleCanvas()).<<(0,MATCH_PARENT).Weight(3).>>.here

          new SRelativeLayout {
            SButton("Pick Brutes", {
              val intent = new Intent(PreBattleActivity.this, classOf[BruteSelectActivity])
              startActivity(intent)
            }).<<.wrap.alignParentTop.>>
            startButton = SButton("Start Level", {
              val intent = new Intent(PreBattleActivity.this, classOf[BattleActivity])
              startActivity(intent)
            }).<<.wrap.centerVertical.>>
            SButton("Menu", {
              finish()
            }).<<.wrap.alignParentBottom.>>
          }.<<(0, MATCH_PARENT).Weight(1).>>.gravity(Gravity.CENTER_HORIZONTAL).here
        }.<<.fill.>>.here
      }
    )
  }

  override def onRestart(): Unit = {
    super.onRestart()
    ()
  }

  override def onResume(): Unit = {
    super.onResume()
    startButton.enabled = game.brutes.exists(_ != null)

    ()
  }
} 
开发者ID:Fellowship-of-the-Bus,项目名称:Brute-Blitzkrieg,代码行数:62,代码来源:PreBattleActivity.scala



注:本文中的android.os.Bundle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala BodyParsers类代码示例发布时间:2022-05-23
下一篇:
Scala Lang类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap