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


Scala LayoutInflater类代码示例

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


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

示例1: CheckableEntryViewHolder

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

import android.view.{LayoutInflater, ViewGroup}
import android.widget.LinearLayout
import sword.langbook.android.TR
import sword.langbook.android.TypedResource._

case class CheckableEntryViewHolder(linearLayout: LinearLayout) extends BaseViewHolder(linearLayout) {
  val textView = linearLayout.findView(TR.conceptPickerEntryCaption)
  val checkBox = linearLayout.findView(TR.conceptPickerSwitch)
}

object CheckableEntryViewHolder {
  def newInstance(parent: ViewGroup) = {
    val inflater = LayoutInflater.from(parent.getContext)
    val view = inflater.inflate(TR.layout.checkable_entry, parent, false)
    new CheckableEntryViewHolder(view)
  }
} 
开发者ID:carlos-sancho-ramirez,项目名称:android-scala-langbook,代码行数:20,代码来源:CheckableEntryViewHolder.scala

示例2: PreferenceFragment

//设置package包名称以及导入依赖的类
package be.mygod.preference

import android.app.DialogFragment
import android.os.Bundle
import android.support.v14.preference.{PreferenceFragment => Base}
import android.support.v7.preference.PreferenceScreen
import android.view.{LayoutInflater, ViewGroup}

abstract class PreferenceFragment extends Base {
  override def onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle) =
    super.onCreateView(inflater, container, savedInstanceState)

  protected final def displayPreferenceDialog(key: String, fragment: DialogFragment) {
    val bundle = new Bundle(1)
    bundle.putString("key", key)
    fragment.setArguments(bundle)
    fragment.setTargetFragment(this, 0)
    getFragmentManager.beginTransaction()
      .add(fragment, "android.support.v14.preference.PreferenceFragment.DIALOG")
      .commitAllowingStateLoss()
  }

  override protected def onCreateAdapter(screen: PreferenceScreen) = new PreferenceGroupAdapter(screen)

  override def onResume {
    super.onResume
    getListView.scrollBy(0, 0)
  }
} 
开发者ID:RoomArchitect,项目名称:test0000,代码行数:30,代码来源:PreferenceFragment.scala

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

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

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

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

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

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

示例9: PkgAdapter

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

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,项目名称:autonotif,代码行数:41,代码来源:PkgAdapter.scala

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

示例11: ConfigView

//设置package包名称以及导入依赖的类
package fr.magistry.taigime2

import Message.Config

import android.content.Context
import android.util.Log
import android.view.{LayoutInflater, View}
import android.view.View.OnClickListener
import android.widget.{Button, CheckBox, Switch}





class ConfigView(context: Context, ime: TaigIME)  {
  val keyFuzzyLookup = "fuzzyLookup"
  val keyPojOrTL = "POJorTL"

  val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE).asInstanceOf[LayoutInflater]
  val view = inflater.inflate(R.layout.config, null)
  val cbFuzzy = view.findViewById(R.id.cbFuzzy).asInstanceOf[CheckBox]
  val swRomanization = view.findViewById(R.id.swPOJTL).asInstanceOf[Switch]
  setValues()

  view
    .findViewById(R.id.acceptConfig)
    .asInstanceOf[Button]
    .setOnClickListener(new OnClickListener {
      override def onClick(v: View): Unit = {
        context.getSharedPreferences("TaigIME2",0)
          .edit()
          .putBoolean(keyFuzzyLookup, cbFuzzy.isChecked)
          .putBoolean(keyPojOrTL,swRomanization.isChecked)
          .apply()
        Log.v("IME","validate config")
        ime.message(Message.ConfigChanged(Config(cbFuzzy.isChecked, swRomanization.isChecked)))
        ime.message(Message.ChangeKeyboard)
      }
    })

  def setValues(): Unit = {
    val prefs = context.getSharedPreferences("TaigIME2", 0)
    val fuzzy = prefs.getBoolean(keyFuzzyLookup,true)
    val pojtr = prefs.getBoolean(keyPojOrTL, false)
    cbFuzzy.setChecked(fuzzy)
    swRomanization.setChecked(pojtr)
  }


} 
开发者ID:a-tsioh,项目名称:TaigIME2,代码行数:51,代码来源:ConfigView.scala


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