本文整理汇总了Scala中android.view.View类的典型用法代码示例。如果您正苦于以下问题:Scala View类的具体用法?Scala View怎么用?Scala View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了View类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: BaseViewHolder
//设置package包名称以及导入依赖的类
package sword.langbook.android.viewholders
import android.support.v7.widget.RecyclerView
import android.view.View
abstract class BaseViewHolder(view: View) extends RecyclerView.ViewHolder(view)
object BaseViewHolder {
object types {
val checkableEntry = 0
val descriptionHeader = 1
val sectionEntry = 2
val sectionHeader = 3
val symbol = 4
}
}
开发者ID:carlos-sancho-ramirez,项目名称:android-scala-langbook,代码行数:17,代码来源:BaseViewHolder.scala
示例2: SymbolDetailsAdapter
//设置package包名称以及导入依赖的类
package sword.langbook.android.activities
import android.support.v7.widget.RecyclerView
import android.view.View.OnClickListener
import android.view.{View, ViewGroup}
import sword.langbook.android.R
import sword.langbook.android.viewholders._
import sword.langbook.db.Symbol
case class SymbolDetailsAdapter(activity: BaseActivity, symbol: Symbol) extends RecyclerView.Adapter[BaseViewHolder] {
val alphabets = symbol.alphabetsWhereIncluded.toVector
val alphabetSectionSize = if (alphabets.nonEmpty) alphabets.size + 1 else 0
override val getItemCount = 1 + alphabetSectionSize
override def getItemViewType(position: Int) = {
if (position == 1) BaseViewHolder.types.sectionHeader
else BaseViewHolder.types.sectionEntry
}
override def onCreateViewHolder(viewGroup: ViewGroup, viewType: Int) = {
viewType match {
case BaseViewHolder.types.`sectionHeader` => SectionHeaderViewHolder.newInstance(viewGroup)
case BaseViewHolder.types.`sectionEntry` => SectionEntryViewHolder.newInstance(viewGroup)
}
}
override def onBindViewHolder(vh: BaseViewHolder, position: Int): Unit = {
vh match {
case holder: SectionHeaderViewHolder =>
holder.textView.setText(activity.getString(R.string.alphabetsWhereIncluded))
case holder: SectionEntryViewHolder =>
val textView = holder.textView
if (position == 0) {
textView.setText(s"Unicode: ${symbol.unicode.toHexString}")
textView.setClickable(false)
}
else {
val alphabet = alphabets(position - 2)
textView.setText(alphabet.suitableTextForLanguage(activity.preferredLanguage).getOrElse(""))
textView.setOnClickListener(new OnClickListener {
override def onClick(v: View): Unit = {
AlphabetDetails.openWith(activity, alphabetEncodedKey = alphabet.key.encoded)
}
})
textView.setClickable(true)
}
}
}
}
开发者ID:carlos-sancho-ramirez,项目名称:android-scala-langbook,代码行数:52,代码来源:SymbolDetailsAdapter.scala
示例3: 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
示例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: FloatingActionMenuBehavior
//设置package包名称以及导入依赖的类
package com.github.shadowsocks.widget
import android.animation.ValueAnimator
import android.content.Context
import android.support.design.widget.CoordinatorLayout
import android.support.design.widget.CoordinatorLayout.Behavior
import android.support.design.widget.Snackbar.SnackbarLayout
import android.support.v4.view.animation.FastOutSlowInInterpolator
import android.util.AttributeSet
import android.view.View
import com.github.clans.fab.FloatingActionMenu
import scala.collection.JavaConverters._
class FloatingActionMenuBehavior(context: Context, attrs: AttributeSet)
extends Behavior[FloatingActionMenu](context, attrs) {
private var fabTranslationYAnimator: ValueAnimator = _
private var fabTranslationY: Float = _
override def layoutDependsOn(parent: CoordinatorLayout, child: FloatingActionMenu, dependency: View) =
dependency.isInstanceOf[SnackbarLayout]
override def onDependentViewChanged(parent: CoordinatorLayout, child: FloatingActionMenu, dependency: View) = {
dependency match {
case _: SnackbarLayout =>
var targetTransY = parent.getDependencies(child).asScala
.filter(view => view.isInstanceOf[SnackbarLayout] && parent.doViewsOverlap(child, view))
.map(view => view.getTranslationY - view.getHeight).reduceOption(_ min _).getOrElse(0F)
if (targetTransY > 0) targetTransY = 0
if (fabTranslationY != targetTransY) {
val currentTransY = child.getTranslationY
if (fabTranslationYAnimator != null && fabTranslationYAnimator.isRunning) fabTranslationYAnimator.cancel
if (child.isShown && Math.abs(currentTransY - targetTransY) > child.getHeight * 0.667F) {
if (fabTranslationYAnimator == null) {
fabTranslationYAnimator = new ValueAnimator
fabTranslationYAnimator.setInterpolator(new FastOutSlowInInterpolator)
fabTranslationYAnimator.addUpdateListener(animation =>
child.setTranslationY(animation.getAnimatedValue.asInstanceOf[Float]))
}
fabTranslationYAnimator.setFloatValues(currentTransY, targetTransY)
fabTranslationYAnimator.start
} else child.setTranslationY(targetTransY)
fabTranslationY = targetTransY
}
}
false
}
override def onStartNestedScroll(parent: CoordinatorLayout, child: FloatingActionMenu, directTargetChild: View,
target: View, nestedScrollAxes: Int) = true
override def onNestedScroll(parent: CoordinatorLayout, child: FloatingActionMenu, target: View, dxConsumed: Int,
dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int) = {
super.onNestedScroll(parent, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed)
val dy = dyConsumed + dyUnconsumed
if (child.isMenuButtonHidden) {
if (dy < 0) child.showMenuButton(true)
} else if (dy > 0) child.hideMenuButton(true)
}
}
开发者ID:mmmyc,项目名称:ssr-android,代码行数:61,代码来源:FloatingActionMenuBehavior.scala
示例6: UndoSnackbarManager
//设置package包名称以及导入依赖的类
package com.github.shadowsocks.widget
import android.support.design.widget.Snackbar
import android.view.View
import com.github.shadowsocks.R
import scala.collection.mutable.ArrayBuffer
class UndoSnackbarManager[T](view: View, undo: Iterator[(Int, T)] => Unit,
commit: Iterator[(Int, T)] => Unit = null) {
private val recycleBin = new ArrayBuffer[(Int, T)]
private val removedCallback = new Snackbar.Callback {
override def onDismissed(snackbar: Snackbar, event: Int) = {
event match {
case Snackbar.Callback.DISMISS_EVENT_SWIPE | Snackbar.Callback.DISMISS_EVENT_MANUAL |
Snackbar.Callback.DISMISS_EVENT_TIMEOUT =>
if (commit != null) commit(recycleBin.iterator)
recycleBin.clear
case _ =>
}
last = null
}
}
private var last: Snackbar = _
def remove(index: Int, item: T) = {
recycleBin.append((index, item))
val count = recycleBin.length
last = Snackbar
.make(view, view.getResources.getQuantityString(R.plurals.removed, count, count: Integer), Snackbar.LENGTH_LONG)
.setCallback(removedCallback).setAction(R.string.undo, (_ => {
undo(recycleBin.reverseIterator)
recycleBin.clear
}): View.OnClickListener)
last.show
}
def flush = if (last != null) last.dismiss
}
开发者ID:mmmyc,项目名称:ssr-android,代码行数:41,代码来源:UndoSnackbarManager.scala
示例7: value
//设置package包名称以及导入依赖的类
package io.taig.android.viewvalue.operation
import android.view.View
import io.taig.android.viewvalue.{ Attribute, Extraction, Injection }
final class value[V <: View]( view: V ) {
def value: Builder = new Builder
class Builder {
def apply[T]( implicit e: Extraction.Value[V, T] ): T = {
e.extract( view )
}
}
def value_=[T]( value: T )( implicit i: Injection.Value[V, T] ): Unit = {
i.inject( view, value )
}
}
开发者ID:Taig,项目名称:viewvalue,代码行数:19,代码来源:value.scala
示例8: findParentTextInputLayout
//设置package包名称以及导入依赖的类
package io.taig.android
import android.support.design.widget.TextInputLayout
import android.view.View
import scala.annotation.tailrec
package object viewvalue {
@tailrec
private[viewvalue] def findParentTextInputLayout( view: View ): Option[TextInputLayout] = {
view.getParent match {
case view: TextInputLayout ? Some( view )
case view: View ? findParentTextInputLayout( view )
case _ ? None
}
}
}
开发者ID:Taig,项目名称:viewvalue,代码行数:18,代码来源:package.scala
示例9: NumberPickerPreferenceDialogFragment
//设置package包名称以及导入依赖的类
package be.mygod.preference
import android.content.Context
import android.support.v14.preference.PreferenceDialogFragment
import android.view.{View, ViewGroup}
class NumberPickerPreferenceDialogFragment extends PreferenceDialogFragment {
private lazy val preference = getPreference.asInstanceOf[NumberPickerPreference]
private lazy val picker = preference.picker
override protected def onCreateDialogView(context: Context) = {
val parent = picker.getParent.asInstanceOf[ViewGroup]
if (parent != null) parent.removeView(picker)
picker
}
override protected def onBindDialogView(view: View) {
super.onBindDialogView(view)
picker.setValue(preference.getValue)
}
override protected def needInputMethod = true
def onDialogClosed(positiveResult: Boolean) {
picker.clearFocus // commit changes
if (positiveResult) {
val value = picker.getValue
if (preference.callChangeListener(value)) preference.setValue(value)
}
}
}
开发者ID:RoomArchitect,项目名称:test0000,代码行数:32,代码来源:NumberPickerPreferenceDialogFragment.scala
示例10: EditTextPreferenceDialogFragment
//设置package包名称以及导入依赖的类
package be.mygod.preference
import android.content.Context
import android.support.v14.preference.PreferenceDialogFragment
import android.view.{View, ViewGroup}
class EditTextPreferenceDialogFragment extends PreferenceDialogFragment {
private lazy val preference = getPreference.asInstanceOf[EditTextPreference]
private lazy val editText = preference.editText
override protected def onCreateDialogView(context: Context) = {
val parent = editText.getParent.asInstanceOf[ViewGroup]
if (parent != null) parent.removeView(editText)
editText
}
override protected def onBindDialogView(view: View) {
super.onBindDialogView(view)
editText.setText(preference.getText)
val text = editText.getText
if (text != null) editText.setSelection(0, text.length)
}
override protected def needInputMethod = true
def onDialogClosed(positiveResult: Boolean) = if (positiveResult) {
val value = editText.getText.toString
if (preference.callChangeListener(value)) preference.setText(value)
}
}
开发者ID:RoomArchitect,项目名称:test0000,代码行数:31,代码来源:EditTextPreferenceDialogFragment.scala
示例11: PreferenceGroupAdapter
//设置package包名称以及导入依赖的类
package be.mygod.preference
import java.lang.reflect.Field
import java.util.List
import android.os.Build
import android.support.v4.content.ContextCompat
import android.support.v4.view.ViewCompat
import android.support.v7.preference.{PreferenceGroup, PreferenceViewHolder, PreferenceGroupAdapter => Old}
import android.view.{LayoutInflater, View, ViewGroup}
import com.github.shadowsocks.R
object PreferenceGroupAdapter {
private var preferenceLayoutsField: Field = _
private var fieldResId: Field = _
private var fieldWidgetResId: Field = _
private val preferenceViewHolderConstructor = classOf[PreferenceViewHolder].getDeclaredConstructor(classOf[View])
{
val oldClass = classOf[Old]
preferenceLayoutsField = oldClass.getDeclaredField("mPreferenceLayouts")
preferenceLayoutsField.setAccessible(true)
val c = oldClass.getDeclaredClasses.filter(c => c.getSimpleName == "PreferenceLayout").head
fieldResId = c.getDeclaredField("resId")
fieldResId.setAccessible(true)
fieldWidgetResId = c.getDeclaredField("widgetResId")
fieldWidgetResId.setAccessible(true)
preferenceViewHolderConstructor.setAccessible(true)
}
}
class PreferenceGroupAdapter(group: PreferenceGroup) extends Old(group) {
import PreferenceGroupAdapter._
protected lazy val preferenceLayouts = preferenceLayoutsField.get(this).asInstanceOf[List[AnyRef]]
override def onCreateViewHolder(parent: ViewGroup, viewType: Int) = if (Build.VERSION.SDK_INT < 21) {
val context = parent.getContext
val inflater = LayoutInflater.from(context)
val pl = preferenceLayouts.get(viewType)
val view = inflater.inflate(fieldResId.get(pl).asInstanceOf[Int], parent, false)
if (view.getBackground == null) {
val array = context.obtainStyledAttributes(null, R.styleable.BackgroundStyle)
var background = array.getDrawable(R.styleable.BackgroundStyle_android_selectableItemBackground)
if (background == null)
background = ContextCompat.getDrawable(context, android.R.drawable.list_selector_background)
array.recycle
val (s, t, e, b) = (ViewCompat.getPaddingStart(view), view.getPaddingTop,
ViewCompat.getPaddingEnd(view), view.getPaddingBottom)
view.setBackground(background)
ViewCompat.setPaddingRelative(view, s, t, e, b)
}
val widgetFrame = view.findViewById(android.R.id.widget_frame).asInstanceOf[ViewGroup]
if (widgetFrame != null) {
val widgetResId = fieldWidgetResId.get(pl).asInstanceOf[Int]
if (widgetResId != 0) inflater.inflate(widgetResId, widgetFrame) else widgetFrame.setVisibility(View.GONE)
}
preferenceViewHolderConstructor.newInstance(view)
} else super.onCreateViewHolder(parent, viewType)
}
开发者ID:RoomArchitect,项目名称:test0000,代码行数:62,代码来源:PreferenceGroupAdapter.scala
示例12: 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
示例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: 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
示例18: 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
示例19: 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
示例20: PkgAdapter
//设置package包名称以及导入依赖的类
package com.yhsif.notifbot
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.ViewGroup
import android.view.View
import scala.collection.mutable.ListBuffer
class PkgAdapter(
var list: ListBuffer[PkgData],
val listener: View.OnClickListener)
extends RecyclerView.Adapter[PkgViewHolder] {
override def onCreateViewHolder(parent: ViewGroup, vt: Int): PkgViewHolder = {
val v =
LayoutInflater
.from(parent.getContext())
.inflate(R.layout.pkg_item, parent, false)
v.setOnClickListener(listener)
return new PkgViewHolder(v)
}
override def onBindViewHolder(vh: PkgViewHolder, i: Int): Unit = {
vh.setIcon(list.apply(i).icon)
vh.setName(list.apply(i).name)
vh.setBackground(i)
}
override def getItemCount(): Int = list.length
override def onAttachedToRecyclerView(rv: RecyclerView): Unit = {
super.onAttachedToRecyclerView(rv)
}
def remove(i: Int) = {
list.remove(i)
notifyDataSetChanged()
}
}
开发者ID:fishy,项目名称:notifbot,代码行数:41,代码来源:PkgAdapter.scala
注:本文中的android.view.View类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论