当前位置: 首页>>代码示例>>Scala>>正文


Scala ImageView类代码示例

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


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

示例1: makeClickable

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

// import android.app.Activity
import org.scaloid.common._
import android.graphics.{Color,ColorMatrix,ColorMatrixColorFilter}
import android.widget.ImageView

package object bruteb {
  def makeClickable(view: ImageView, clickable: Boolean): view.type = {
    view.clickable = clickable
    val colors = new ColorMatrix()
    colors.setSaturation(if (view.clickable) 1 else 0)
    val filter = new ColorMatrixColorFilter(colors)
    view.setColorFilter(filter)
    view
  }

  def selectButton(button: SImageButton): Unit = {
    val _ = button.enabled = false
  }

  def deselectButton(button: SImageButton): Unit = {
    val _ = button.enabled = true
  }
} 
开发者ID:Fellowship-of-the-Bus,项目名称:Brute-Blitzkrieg,代码行数:26,代码来源:package.scala

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

示例3: PictureDisplay

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

import java.io._
import android.content.{Context, Intent}

import ru.wordmetrix.dreamcrammer.db._
import ru.wordmetrix._

import android.view.{Menu, MenuItem, View, ViewGroup, LayoutInflater}
import android.widget.{ToggleButton, TextView, Button, CompoundButton, ImageView, ArrayAdapter, ListView, PopupMenu, AdapterView, GridView}
import android.graphics.{BitmapFactory,Bitmap}
import android.support.v4.util.LruCache

class PictureDisplay(context : DreamCrammerBase, picture : Picture) extends  BaseDisplay(context) {
    override
    def item(resource : Int = R.layout.pictureitem) = super.item(resource)

    override
    def item(viewgroup : ViewGroup) : ViewGroup =  {
        val imageView : ImageView = viewgroup.findViewById(R.id.picture_body).asInstanceOf[ImageView]
        //log("picture %s %s %s", imageView, picture, picture.body.size)
        // ticket : Add a message that something is wrong with picture instead of silent droping it

        picture.bodyOption match {
            case Some(body) => try {
                imageView.setImageBitmap(Bitmap.createScaledBitmap(BitmapFactory.decodeByteArray(body,0,picture.body.size),256,256,true) )
                //imageView.setImageBitmap(BitmapFactory.decodeByteArray(body,0,picture.body.size))
            } catch {
                case x : Throwable => log("Bitmap is broken",x)
            }

            case None => log("Bitmap has not been loaded yet")
        }

        
        viewgroup
    }

    override
    def view(resource : Int = R.layout.pictureview) : ViewGroup  = super.view(resource)

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

示例4: ScaledImageView

//设置package包名称以及导入依赖的类
package ru.wordmetrix.dreamcrammer
import android.widget.ImageView
import android.content.{Context}
import android.util.AttributeSet
import android.view.{MenuInflater,MenuItem, View}

import ru.wordmetrix.dreamcrammer.db._
import ru.wordmetrix._

class ScaledImageView(context : Context, attrs : AttributeSet, defStyle : Int) extends ImageView(context, attrs, defStyle) {
    log("ScaledImageMenu attrs: %s", attrs)

    def this(context : Context, attrs : AttributeSet) = this(context, attrs, 0)

    def this(context : Context) = this(context, null, 0)

    override
    def onMeasure (widthMeasureSpec : Int, heightMeasureSpec : Int) : Unit = {
        log("onMeasure", widthMeasureSpec, heightMeasureSpec)
        super.onMeasure(widthMeasureSpec, heightMeasureSpec)
    }
} 
开发者ID:electricmind,项目名称:dreamcrammer,代码行数:23,代码来源:scaledimageview.scala

示例5: DreamCrammerBase

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

import java.io._
import android.app.Activity
import android.content.Context
import android.os.{Bundle}

import ru.wordmetrix.dreamcrammer.db._
import ru.wordmetrix._

import android.view.{View, ViewGroup, LayoutInflater}
import android.widget.{ToggleButton, TextView, CompoundButton, ImageView, ArrayAdapter, ListView}
import android.graphics.{BitmapFactory,Bitmap}
import android.support.v4.app.FragmentActivity

abstract 
class DreamCrammerBase extends FragmentActivity with MenuBase with PlayerBase {

    def layout : Int
    lazy val preferences = new PreferencesBase("DreamCrammer", this)
    lazy val db : DB = new SQLiteAndroid(this, "taylor.db", true)
    lazy val convertors = new Convertors()(db)
    import convertors._

    override
    def onStop() = {
        super.onStop()
        db.close()
    }

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

   def display(viewGroup : ViewGroup, picture : Picture) = {
       val imageView : ImageView = viewGroup.findViewById(R.id.picture_body).asInstanceOf[ImageView]
       
       picture.bodyOption.map(body =>
           imageView.setImageBitmap( BitmapFactory.decodeByteArray(body,0,body.size) )
       )

       viewGroup
   }


   def display(viewGroup : ViewGroup, word : Word) = {
        log("display %s %s",viewGroup, word)
        new WordDisplay(this, word).view(viewGroup)
        viewGroup.findViewById(R.id.word_is_seen).asInstanceOf[ToggleButton].setChecked(word.is_seen)
        viewGroup.findViewById(R.id.word_is_seen).asInstanceOf[ToggleButton].setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            def onCheckedChanged(buttonView : CompoundButton, isChecked : Boolean) = word.is_seen(isChecked)
        })

        viewGroup
    }


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

示例6: ImageCombinators

//设置package包名称以及导入依赖的类
package tryp
package droid
package view
package io

import android.widget.ImageView

import view.core.annotation.contextfold
import view.core.Combinators

package object image
extends ImageCombinators

abstract class ImageCombinators
extends Combinators[ImageView]
{
  def imageId(id: Int) = k(_.setImageResource(id))

  @contextfold def imageRes(name: String) = {
    res.theme.drawable(name)
      .map(d => (_: ImageView).setImageDrawable(d))
  }
} 
开发者ID:tek,项目名称:droid,代码行数:24,代码来源:image.scala

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

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

示例9: 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.ImageView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。