本文整理汇总了Scala中android.widget.TextView类的典型用法代码示例。如果您正苦于以下问题:Scala TextView类的具体用法?Scala TextView怎么用?Scala TextView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextView类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: PkgViewHolder
//设置package包名称以及导入依赖的类
package com.yhsif.notifbot
import android.graphics.drawable.Drawable
import android.support.v7.widget.RecyclerView
import android.view.View
import android.widget.ImageView
import android.widget.TextView
class PkgViewHolder(v: View) extends RecyclerView.ViewHolder(v) {
def setIcon(icon: Drawable) = {
v.findViewById(R.id.icon).asInstanceOf[ImageView].setImageDrawable(icon)
}
def setName(name: String) = {
v.findViewById(R.id.name).asInstanceOf[TextView].setText(name)
}
def setBackground(i: Int) = {
if (i % 2 == 0) {
v.setBackgroundColor(v.getContext().getColor(R.color.even_background))
} else {
v.setBackgroundColor(v.getContext().getColor(R.color.odd_background))
}
}
}
开发者ID:fishy,项目名称:notifbot,代码行数:26,代码来源:PkgViewHolder.scala
示例2: CurrencyDetailsActivity
//设置package包名称以及导入依赖的类
package app.bitrader.activity
import android.os.Bundle
import android.widget.{LinearLayout, TextView}
import app.bitrader.activity.layouts.BasicLayout
import app.bitrader.api.poloniex.Currency
import macroid.ContextWrapper
import macroid.FullDsl._
class CurrencyDetailsActivity extends BaseActivity {
private val maybeCurrency = getParam[Currency]
private lazy val layout = new CurrencyDetailsLayout(maybeCurrency)
override def onCreate(b: Bundle): Unit = {
super.onCreate(b)
setContentView(layout.ui)
}
}
class CurrencyDetailsLayout(maybeCurrency: Option[Currency])(implicit cw: ContextWrapper) extends BasicLayout {
def ui = l[LinearLayout](
w[TextView] <~ (maybeCurrency map (c => text(c.name)))
).get
}
开发者ID:aafa,项目名称:bitrader,代码行数:26,代码来源:CurrencyDetailsActivity.scala
示例3: 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
示例4: 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
示例5: colorizeToolbar
//设置package包名称以及导入依赖的类
package app.bitrader.helpers.activity
import android.graphics.{PorterDuff, PorterDuffColorFilter}
import android.support.v7.widget.Toolbar
import android.view.View
import android.widget.{ActionMenuView, ImageButton, TextView}
import app.bitrader.helpers.AdditionalTweaks
import macroid.{ContextWrapper, Transformer}
import macroid._
trait ActivityStyles extends AdditionalTweaks{
def colorizeToolbar(toolbar: Toolbar, color: Int) = {
val filter: PorterDuffColorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY)
toolbar.setTitleTextColor(color)
toolbar.setSubtitleTextColor(color)
println("applyThemeColors " + toolbar.getTitle)
for (i <- 0 to toolbar.getChildCount) {
val view: View = toolbar.getChildAt(i)
println("apply styles view " + view)
view match {
case v: ImageButton => v.getDrawable.setColorFilter(filter)
case t: TextView => t.setTextColor(color)
case am: ActionMenuView =>
case _ =>
}
}
}
def fitsAll(implicit c: ContextWrapper): Transformer = {
Transformer {
case a => a <~ fits
}
}
}
开发者ID:aafa,项目名称:bitrader,代码行数:42,代码来源:ActivityStyles.scala
示例6: LocationTweaks
//设置package包名称以及导入依赖的类
package org.pragmas.android.RestSensors.Tweaks
import android.widget.{Button, TextView}
import macroid._
import macroid.FullDsl._
import macroid.contrib._
import android.widget.TableLayout
import org.pragmas.android.RestSensors.Contexts
import org.pragmas.android.RestSensors.Sensors.Location
object LocationTweaks {
import ConstantsTweak._
protected val sensor = Location
protected val resumeText = "Resume Location"
protected val pauseText = "Pause Location"
private var dataSlot = slot[TextView]
private var buttonSlot = slot[Button]
def button (implicit appCtx: ContextWrapper) = {
val caption = if (sensor.paused) resumeText else pauseText
w[Button] <~ wire(buttonSlot) <~ (TextTweaks.size(textSize) + text(caption)) <~ On.click {
sensor.setLogToTextView(dataSlot.get)
if (sensor.paused) {
sensor.resumeReadData()
buttonSlot <~ text(pauseText)
} else {
sensor.pauseReadData()
buttonSlot <~ text(resumeText)
}
}
}
def data (implicit appCtx: ContextWrapper) = {
w[TextView] <~ wire(dataSlot) <~ TextTweaks.size(textSize) + text(sensor.sensorData.toJSONString('pretty)) + show
}
def tweaks() : Ui[TableLayout] = {
implicit val appCtx = Contexts.context
l[TableLayout](button,data)
}
}
开发者ID:minimalprocedure,项目名称:Android-Sensors-REST,代码行数:45,代码来源:LocationTweaks.scala
示例7: button
//设置package包名称以及导入依赖的类
package org.pragmas.android.RestSensors.Tweaks
import android.widget.{Button, TextView}
import macroid._
import macroid.FullDsl._
import macroid.contrib._
import android.widget.TableLayout
import org.pragmas.android.RestSensors.Contexts
import org.pragmas.android.RestSensors.Sensors._
//import android.util.Log
trait BasicSensorTweaks {
import ConstantsTweak._
protected val sensor : BasicSensorListener
protected val resumeText = "resume"
protected val pauseText = "pause"
private var dataSlot = slot[TextView]
private var buttonSlot = slot[Button]
def button (implicit appCtx: ContextWrapper) = {
val caption = if (sensor.paused) resumeText else pauseText
w[Button] <~ wire(buttonSlot) <~ (TextTweaks.size(textSize) + text(caption)) <~ On.click {
sensor.setLogToTextView(dataSlot.get)
if (sensor.paused) {
sensor.resumeReadData()
buttonSlot <~ text(pauseText)
} else {
sensor.pauseReadData()
buttonSlot <~ text(resumeText)
}
}
}
def data (implicit appCtx: ContextWrapper) = {
w[TextView] <~ wire(dataSlot) <~ TextTweaks.size(textSize) + text(sensor.sensorData.toJSONString('pretty)) + show
}
def tweaks() : Ui[TableLayout] = {
implicit val appCtx = Contexts.context
l[TableLayout](button, data)
}
}
开发者ID:minimalprocedure,项目名称:Android-Sensors-REST,代码行数:46,代码来源:BasicSensorTweaks.scala
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: PkgViewHolder
//设置package包名称以及导入依赖的类
package com.yhsif.autonotif
import android.graphics.drawable.Drawable
import android.support.v7.widget.RecyclerView
import android.view.View
import android.widget.ImageView
import android.widget.TextView
class PkgViewHolder(v: View) extends RecyclerView.ViewHolder(v) {
def setIcon(icon: Drawable) = {
v.findViewById(R.id.icon).asInstanceOf[ImageView].setImageDrawable(icon)
}
def setName(name: String) = {
v.findViewById(R.id.name).asInstanceOf[TextView].setText(name)
}
def setBackground(i: Int) = {
if (i % 2 == 0) {
v.setBackgroundColor(v.getContext().getColor(R.color.even_background))
} else {
v.setBackgroundColor(v.getContext().getColor(R.color.odd_background))
}
}
}
开发者ID:fishy,项目名称:autonotif,代码行数:26,代码来源:PkgViewHolder.scala
示例13: CitySpinner
//设置package包名称以及导入依赖的类
package com.happyheal.happyhealapp.ui.main
import android.view.{LayoutInflater, ViewGroup, View}
import android.widget.{ImageView, TextView, SpinnerAdapter, BaseAdapter}
import com.happyheal.happyhealapp.R
import macroid.ActivityContextWrapper
class CitySpinner(cities: List[String])(implicit activityContextWrapper: ActivityContextWrapper)
extends BaseAdapter with SpinnerAdapter {
override def getItemId(i: Int): Long = i
override def getCount: Int = cities.length
override def getView(i: Int, view: View, viewGroup: ViewGroup): View = {
val rootView = LayoutInflater.from(activityContextWrapper.application).inflate(R.layout.spinner_item, viewGroup, false)
val textView = rootView.findViewById(R.id.spinner_item_text).asInstanceOf[TextView]
val chevron = rootView.findViewById(R.id.chevron).asInstanceOf[ImageView]
chevron.setColorFilter(activityContextWrapper.application.getResources.getColor(R.color.colorPrimary))
textView.setText(cities(i).toString)
rootView
}
override def getDropDownView(position: Int, convertView: View, parent: ViewGroup): View = {
val rootView = LayoutInflater.from(activityContextWrapper.application).inflate(R.layout.spinner_dropdown, parent, false)
val textView = rootView.findViewById(R.id.city_dropdown_text).asInstanceOf[TextView]
textView.setText(cities(position).toString)
rootView
}
override def getItem(i: Int): AnyRef = cities(i)
}
开发者ID:pamu,项目名称:happyheal,代码行数:35,代码来源:CitySpinner.scala
示例14: StepFragment
//设置package包名称以及导入依赖的类
package com.happyheal.happyhealapp.ui.wizard
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.View.OnClickListener
import android.view.{View, ViewGroup, LayoutInflater}
import android.widget.{Button, TextView, ImageView}
import com.happyheal.happyhealapp.R
import com.happyheal.happyhealapp.ui.main.MainActivity
import macroid.Contexts
class StepFragment extends Fragment
with Contexts[Fragment] {
override def onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle): View = {
val steps = Steps.steps
val element = getArguments.getInt(StepFragment.keyStepPosition)
val step = steps(element)
implicit val rootView = inflater.inflate(R.layout.step_layout, container, false)
initView(step)
rootView
}
private def initView(step: Step)(implicit view: View): Unit = {
val imageView = view.findViewById(R.id.image).asInstanceOf[ImageView]
val titleView = view.findViewById(R.id.title).asInstanceOf[TextView]
val descriptionView = view.findViewById(R.id.description).asInstanceOf[TextView]
titleView.setText(step.title)
descriptionView.setText(step.description)
imageView.setImageResource(step.image)
}
}
object StepFragment {
val keyStepPosition = "key_step_position"
}
开发者ID:pamu,项目名称:happyheal,代码行数:42,代码来源:StepFragment.scala
注:本文中的android.widget.TextView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论