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

Scala Activity类代码示例

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

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



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

示例1: AlphabetDetailsAdapter

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

import android.app.Activity
import android.support.v7.widget.RecyclerView
import android.util.DisplayMetrics
import android.view.View.OnClickListener
import android.view.{View, ViewGroup}
import sword.langbook.android.R
import sword.langbook.android.viewholders.SymbolViewHolder
import sword.langbook.db.Alphabet

object AlphabetDetailsAdapter {

  def apply(activity: Activity, alphabet: Alphabet) = {
    val metrics = new DisplayMetrics()
    activity.getWindowManager.getDefaultDisplay.getMetrics(metrics)

    val columns = metrics.widthPixels / activity.getResources.getDimensionPixelSize(R.dimen.alphabetDetailsSymbolSide)
    new AlphabetDetailsAdapter(activity, alphabet, columns)
  }
}

case class AlphabetDetailsAdapter(activity: Activity, alphabet: Alphabet, spanCount: Int) extends RecyclerView.Adapter[SymbolViewHolder] {
  val symbols = alphabet.symbols.toSeq.sortWith(_.unicode < _.unicode)
  val chars = symbols.map(_.unicode.toChar)
  override val getItemCount = symbols.size

  override def onCreateViewHolder(viewGroup: ViewGroup, viewType: Int) = {
    SymbolViewHolder.newInstance(viewGroup)
  }

  override def onBindViewHolder(vh: SymbolViewHolder, position: Int): Unit = {
    vh.textView.setText("" + chars(position))
    vh.textView.setOnClickListener(new OnClickListener {
      override def onClick(v: View): Unit = {
        SymbolDetails.openWith(activity, symbol = symbols(position))
      }
    })
  }
} 
开发者ID:carlos-sancho-ramirez,项目名称:android-scala-langbook,代码行数:41,代码来源:AlphabetDetailsAdapter.scala


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


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


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


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


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


示例7: RalletsWebClient

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

import android.app.{Activity, AlertDialog, ProgressDialog}
import android.content.DialogInterface
import android.webkit.{WebView, WebViewClient}
import android.widget.Toast
import com.github.shadowsocks.R

class RalletsWebClient(activity: Activity, title: String) extends WebViewClient {
  val alertDialog = new AlertDialog.Builder(activity).create()
  val progressBar = ProgressDialog.show(activity, title, activity.getString(R.string.loading))

  override def onReceivedSslError(view: _root_.android.webkit.WebView, handler: _root_.android.webkit.SslErrorHandler, error: _root_.android.net.http.SslError): Unit = {
    import android.content.DialogInterface
    val builder = new AlertDialog.Builder(activity)
    builder.setMessage(R.string.ssl_error_alert)
    builder.setPositiveButton(R.string.continue_browse, new DialogInterface.OnClickListener() {
      override def onClick(dialog: DialogInterface, which: Int): Unit = {
        handler.proceed
      }
    })
    builder.setNegativeButton(R.string.cancel_browse, new DialogInterface.OnClickListener() {
      override def onClick(dialog: DialogInterface, which: Int): Unit = {
        handler.cancel
      }
    })
    val dialog = builder.create
    dialog.show()
  }

  override def shouldOverrideUrlLoading(view: WebView, url: String): Boolean =  {
    view.loadUrl(url)
    return false
  }

  override def onPageFinished(view: WebView, url: String): Unit = {
    RUtils.log("Finished loading URL: " + url)
    if (progressBar.isShowing()) {
      progressBar.dismiss()
    }
  }

  override def onReceivedError(view: WebView, errorCode: Int, description: String, failingUrl: String): Unit = {
    RUtils.log("Error: " + description)
    Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show()
    alertDialog.setTitle("Error")
    alertDialog.setMessage(description)
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
      def onClick(dialog: DialogInterface, which: Int) {}
    })
    alertDialog.show()
  }
} 
开发者ID:rallets-network,项目名称:rallets-android,代码行数:54,代码来源:RalletsWebClient.scala


示例8: ReadQrActivity

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

import android.app.Activity
import android.graphics.PointF
import android.os.Bundle
import android.widget.{Button, LinearLayout, TextView}
import app.bitrader.activity.MainStyles
import com.google.zxing.Result
import macroid.{Contexts, Ui}
import macroid.FullDsl._
import macroid._
import me.dm7.barcodescanner.zxing.ZXingScannerView


class ReadQrActivity extends Activity with Contexts[Activity] with ZXingScannerView.ResultHandler with MainStyles {

  override def onCreate(savedInstanceState: Bundle): Unit = {
    super.onCreate(savedInstanceState)
    setContentView(ui)
  }

  var qrText = slot[TextView]

  def ui = {
    l[LinearLayout](
      w[TextView] <~ wire(qrText) <~ vWrap,
      w[Button] <~ text("read qr") <~ onClick(runQr) <~ vWrapContent
    ) <~ vMatchWidth
  }.get

  lazy val scannerView: ZXingScannerView = new ZXingScannerView(this)

  def runQr: Unit = {
    setContentView(scannerView)
    scannerView.setResultHandler(this)
    scannerView.startCamera()
  }

  override def onPause(): Unit = {
    super.onPause()
    scannerView.stopCamera()
  }

  override def handleResult(result: Result): Unit = {
    setContentView(ui)
    println(s"got qr! ${result.getText}")
    Ui.run(qrText <~ text(result.getText))

    scannerView.stopCamera()
  }


} 
开发者ID:aafa,项目名称:bitrader,代码行数:54,代码来源:ReadQrActivity.scala


示例9: ProfileActivity

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

import android.app.Activity
import android.os.Bundle
import android.widget.TextView
import app.bitrader.activity.Circuitable
import app.bitrader.api.apitest.ApiTest
import app.bitrader.api.common.UserProfile
import app.bitrader.{AppCircuit, RootModel}
import diode.ModelR
import macroid.{ContextWrapper, Contexts}
import macroid.FullDsl._


class ProfileActivity extends Activity with Contexts[Activity] with Circuitable{
  private lazy val view: ProfileView = new ProfileView(appCircuit.serviceContext.zoom(_.auth))

  override def onCreate(savedInstanceState: Bundle): Unit = {
    super.onCreate(savedInstanceState)
    setContentView(view.ui)
  }
}

class ProfileView(m: ModelR[RootModel, UserProfile])(implicit cw: ContextWrapper) {
  def ui = {
    w[TextView] <~ text(m.value.authData.get.apiKey)
  }.get
} 
开发者ID:aafa,项目名称:bitrader,代码行数:29,代码来源:ProfileActivity.scala


示例10: startActivity

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

import android.app.Activity
import android.content.Intent
import app.bitrader.helpers.activity.PassableType.Passable
import macroid.ContextWrapper

import scala.collection.mutable
import scala.reflect._


trait ActivityOperations {

  @inline def startActivity[T: ClassTag](implicit context: ContextWrapper): Unit = context.bestAvailable.startActivity(IntentObject[T])

  @inline def startActivityWithParams[A <: Activity : ClassTag](o: Passable*)(implicit context: ContextWrapper): Unit = {
    if (o != null) {
      PassParams.array ++= o
    } else {
      PassParams.array.clear()
    }
    this.startActivity[A]
  }

  @inline def getParam[T <: Passable : ClassTag]: Option[T] = {
    val maybePassable: Option[T] = PassParams.array.find(p => classTag[T].runtimeClass.isInstance(p)).asInstanceOf[Option[T]]
    PassParams.array.clear() // todo remove only pick
    maybePassable
  }

  implicit class ActivityHelper(a: Activity) {
    def changeTheme(theme: Int) = {
      a.setTheme(theme)
      a.finish()
      a.startActivity(new Intent(a, a.getClass))
    }
  }
}

object IntentObject {
  @inline def apply[T](implicit context: ContextWrapper, mt: ClassTag[T]) = new Intent(context.bestAvailable, mt.runtimeClass)
}

object PassParams {
  var array = mutable.ArrayBuffer[Passable]()
}

object PassableType{
  type Passable = AnyRef
} 
开发者ID:aafa,项目名称:bitrader,代码行数:51,代码来源:ActivityOperations.scala


示例11: DescriptionAddDialog

//设置package包名称以及导入依赖的类
package ru.wordmetrix.dreamcrammer


import android.app.{ Activity, Dialog, AlertDialog }
import android.os.{ Bundle }
import ru.wordmetrix.dreamcrammer.db._
import ru.wordmetrix._
import android.content.{ Context, DialogInterface }
import android.view.{ LayoutInflater, ViewGroup }
import android.widget.{ EditText }
import android.support.v4.app.DialogFragment


object DescriptionAddDialog {
    abstract trait Listener {
        def publish(word: Word): Unit
    }
}

class DescriptionAddDialog(word: Word) extends DialogFragment {
    var activity: DescriptionAddDialog.Listener = null

     override def onAttach(activity: Activity) {
        super.onAttach(activity)
        this.activity = activity.asInstanceOf[DescriptionAddDialog.Listener]
    }

    override def onCreateDialog(savedInstanceState: Bundle): Dialog = {
        val viewgroup = getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE).asInstanceOf[LayoutInflater].inflate(R.layout.descriptiondialog, null).asInstanceOf[ViewGroup]
        log("edit : %s", viewgroup.findViewById(R.id.description_value).asInstanceOf[EditText])

        new AlertDialog.Builder(getActivity())
            .setTitle("Add description")
            .setView(viewgroup)
            .setPositiveButton("Add", new DialogInterface.OnClickListener() {
                def onClick(dialog: DialogInterface, id: Int) {
                    log("Add description")
                    word.addDescription(viewgroup.findViewById(R.id.description_value).asInstanceOf[EditText].getText().toString)
                    activity.publish(word.refresh())
                }
            })
            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                def onClick(dialog: DialogInterface, id: Int) {
                    log("Cancel changes")
                }
            }).create()
    }

} 
开发者ID:electricmind,项目名称:dreamcrammer,代码行数:50,代码来源:descriptionedit.scala


示例12: MainActivity

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


import android.app.Activity
import android.os.Bundle
import android.widget.{LinearLayout, TextView}
import com.github.aafa.model.User
import io.realm.RealmConfiguration.Builder
import io.realm._
import macroid.FullDsl._
import macroid._



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

  def realmConfiguration: RealmConfiguration = new Builder(this)
    .deleteRealmIfMigrationNeeded()
    .build()

  def realm: Realm = Realm.getInstance(realmConfiguration)

  override def onCreate(b: Bundle): Unit = {
    super.onCreate(b)
    setTitle("Hello world, realm-test!")
    setContentView(ui.get)
    test()
  }

  def test(): Unit = {
    val user: User = new User()
    user.name = "Hello, Realm!"
    user.id = 1

    realm.beginTransaction()
    realm.clear(classOf[User])
    realm.copyToRealm(user)
    realm.commitTransaction()

    val realmUser: User = realm.where(classOf[User]).equalTo("id", new Integer(1)).findFirst()
    updateText(realmUser.name)
    println(realmUser.name)
  }

}

trait MainActivityView {
  this: MainActivity =>

  var textSlot = slot[TextView]

  def ui: Ui[LinearLayout] = {
    l[LinearLayout](
      w[TextView] <~ wire(textSlot)
    )
  }

  def updateText(s: String) = runUi(textSlot <~ text(s))
} 
开发者ID:aafa,项目名称:realm-sbt-plugin,代码行数:60,代码来源:MainActivity.scala


示例13: ExampleRecordView

//设置package包名称以及导入依赖的类
package com.example.hyenawarrior.dictionary.modelview.meaning_panel

import android.app.Activity
import android.view.{View, ViewGroup}
import android.widget.{EditText, TextView}
import com.example.hyenawarrior.dictionary.modelview.{DynamicListView, EditTextTypeListener}
import com.example.hyenawarrior.myapplication.R


class ExampleRecordView(activity: Activity, hostView: ViewGroup) extends DynamicListView[String](hostView, R.layout.example_record, activity)
{
	private var examples: Map[View, String] = Map()

	ensureToHaveExtraRecord()

	override protected def applyToView(optElem: Option[String], recordView: View): Unit =
	{
		val elem = optElem getOrElse ""

		val idx = examples.size + 1
		val etExample = recordView.findViewById(R.id.et_setmeaning_Example).asInstanceOf[EditText]
		etExample addTextChangedListener new EditTextTypeListener(onMeaningChange(recordView))
		etExample.setText(elem, TextView.BufferType.EDITABLE)

		val tvIndex = recordView.findViewById(R.id.tv_setmeaning_Example_Index).asInstanceOf[TextView]
		tvIndex setText s"$idx"
	}

	private def onMeaningChange(recordView: View)(text: String): Unit =
	{
		examples = (examples - recordView) + ((recordView, text))

		ensureToHaveExtraRecord()
	}


	private def ensureToHaveExtraRecord(): Unit =
	{
		val countOfEmptyRecords = examples.collect { case (_, str) if str.isEmpty => 1 }.sum

		countOfEmptyRecords match
		{
			case 0 => add("")
			case n if n > 1 =>
				for (v <- examples.collectFirst	{ case (v, str) if str.isEmpty => v })
				{
					examples = examples - v
					remove(v)
				}

			case _ => ()
		}
	}

	def fetch(): Seq[String] = examples.values.filter(_.nonEmpty).toSeq
} 
开发者ID:HyenaSoftware,项目名称:IG-Dictionary,代码行数:57,代码来源:ExampleRecordView.scala


示例14: NounDeclensionAdapter

//设置package包名称以及导入依赖的类
package com.example.hyenawarrior.dictionary.modelview.add_new_word_panel

import android.app.Activity
import android.view.{View, ViewGroup}
import android.widget.{Button, TextView}
import com.example.hyenawarrior.dictionary.model.database.marshallers.NounForm
import com.example.hyenawarrior.dictionary.modelview.CustomAdapter
import com.example.hyenawarrior.myapplication.R
import com.hyenawarrior.OldNorseGrammar.grammar.nouns.stemclasses.NounStemClassEnum


object NounDeclensionAdapter
{
	val NOUN_EDIT_TEXTS = List(
		(R.id.tvNewWord_Nom_Sg, 	NounForm.NOUN_NOM_SG)
		, (R.id.tvNewWord_Acc_Sg, NounForm.NOUN_ACC_SG)
		, (R.id.tvNewWord_Dat_Sg, NounForm.NOUN_DAT_SG)
		, (R.id.tvNewWord_Gen_Sg, NounForm.NOUN_GEN_SG)

		, (R.id.tvNewWord_Nom_Pl, NounForm.NOUN_NOM_PL)
		, (R.id.tvNewWord_Acc_Pl, NounForm.NOUN_ACC_PL)
		, (R.id.tvNewWord_Dat_Pl, NounForm.NOUN_DAT_PL)
		, (R.id.tvNewWord_Gen_Pl, NounForm.NOUN_GEN_PL)
	)
}

class NounDeclensionAdapter(activity: Activity) extends CustomAdapter[(NounStemClassEnum, Map[NounForm, String])](activity)
{
	override protected def getNewView(i: Int, viewGroup: ViewGroup): View =
	{
		val isSingleList = getCount == 1

		val view = inflater.inflate(R.layout.noun_declension, viewGroup, false)

		val (nscEnum @ NounStemClassEnum(ncName, _), map) = itemAt(i)

		//
		val tvNounDeclDesc = view.findViewById(R.id.tvNounDeclDesc).asInstanceOf[TextView]
		tvNounDeclDesc.setText(if (isSingleList)	"" else ncName)

		NounDeclensionAdapter.NOUN_EDIT_TEXTS.foreach
		{
			case (id, nf) =>
				val tvNC = view.findViewById(id).asInstanceOf[TextView]
				val ncTextForm = map.getOrElse(nf, "...")
				tvNC.setText(ncTextForm)
		}

    // tag the select button
    val tv_addword_noun_Select = view.findViewById(R.id.tv_addword_noun_Select).asInstanceOf[Button]
    tv_addword_noun_Select.setTag(nscEnum)

		view
	}

  def getSelectorTagOf(view: View): Option[NounStemClassEnum] = view match
  {
    case btn: Button => Option(btn.getTag.asInstanceOf[NounStemClassEnum])
    case _ => None
  }
} 
开发者ID:HyenaSoftware,项目名称:IG-Dictionary,代码行数:62,代码来源:NounDeclensionAdapter.scala


示例15: WordFormAdapter

//设置package包名称以及导入依赖的类
package com.example.hyenawarrior.dictionary.modelview

import android.app.Activity
import android.view.{View, ViewGroup}
import android.widget.TextView
import com.example.hyenawarrior.myapplication.R
import com.hyenawarrior.OldNorseGrammar.grammar._
import com.hyenawarrior.OldNorseGrammar.grammar.nouns.Noun
import com.hyenawarrior.OldNorseGrammar.grammar.verbs.{FinitiveStrongVerb, NonFinitiveStrongVerb, NonFinitiveVerbType}


class WordFormAdapter(activity: Activity) extends CustomAdapter[Word](activity)
{
	override def getNewView(i: Int, viewGroup: ViewGroup): View =
	{
		val view = inflater.inflate(R.layout.word_form_entry, viewGroup)
		//val rootLayout = view.asInstanceOf[GridLayout]

		val item = itemAt(i)

		val tvWordForm = view.findViewById(R.id.tvWordForm).asInstanceOf[TextView]
		val tvWordDesc = view.findViewById(R.id.tvWordDesc).asInstanceOf[TextView]

		tvWordForm setText item.strForm
		//tvWordDesc setText formatTraits(item.traits)

		val formDesc = item.pos match
		{
			case n: Noun => s"[${shortCut(n.decl._1)}, ${shortCut(n.decl._2)}]"
			case v: FinitiveStrongVerb => s"[${shortCut(v.pronoun.number)}, ${v.pronoun.person}]"
			case v: NonFinitiveStrongVerb => s"[${shortCut(v.nonFinitiveVerbType)}]"
			case _ => "???"
		}

		tvWordDesc setText formDesc

		view
	}

	def formatTraits(trs: List[DescriptorFlag]): String = trs.map(t => shortCut(t)).mkString("[", ", ", "]")

	def shortCut(df: Any) = df match
	{
		case Case.NOMINATIVE => "nom"
		case Case.ACCUSATIVE => "acc"
		case Case.DATIVE => "dat"
		case Case.GENITIVE => "gen"
		case GNumber.SINGULAR => "sg"
		case GNumber.PLURAL => "pl"
		case NonFinitiveVerbType.INFINITIVE => "inf"
		case NonFinitiveVerbType.PRESENT_PARTICIPLE => "present part."
		case NonFinitiveVerbType.PAST_PARTICIPLE => "past part."
	}
} 
开发者ID:HyenaSoftware,项目名称:IG-Dictionary,代码行数:55,代码来源:WordFormAdapter.scala


示例16: AbstractAddNewPosHelper

//设置package包名称以及导入依赖的类
package com.example.hyenawarrior.myapplication.new_word.new_pos_helpers

import android.app.Activity
import android.view.View
import android.widget.{ArrayAdapter, Spinner}


abstract class AbstractAddNewPosHelper(activity: Activity, spSelectStemClass: Spinner, spinnerItemRsrc: Int) extends AddNewPosHelper
{
	def activate(): Unit =
	{
		val adapter = ArrayAdapter.createFromResource(activity,	spinnerItemRsrc, android.R.layout.simple_spinner_item)
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
		spSelectStemClass.setAdapter(adapter)
	}

	def deactivate(): Unit = ()

	private lazy val priFormSetter = createOverrideFormSetter(true)

	override def primaryFromSetter(): View = priFormSetter
} 
开发者ID:HyenaSoftware,项目名称:IG-Dictionary,代码行数:23,代码来源:AbstractAddNewPosHelper.scala


示例17: MainActivity

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

import android.app.Activity
import android.os.Bundle

class MainActivity extends Activity with TypedFindView {
    lazy val textview = findView(TR.text)

    
    override def onCreate(savedInstanceState: Bundle): Unit = {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.main)
        textview.setText("Hello world, from Foo")
        println(R.xml.global_tracker)
        println(R.string.gcm_defaultSenderId)
        println(R.string.google_crash_reporting_api_key)
        println(R.string.google_app_id)
        println(R.string.default_web_client_id)
    }
} 
开发者ID:scala-android,项目名称:sbt-android-gms,代码行数:21,代码来源:sample.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala HttpEntity类代码示例发布时间:2022-05-23
下一篇:
Scala OAuthAuthorization类代码示例发布时间: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