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


Scala ArrayAdapter类代码示例

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


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

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

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


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