• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala ViewGroup类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了ViewGroup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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: ConceptPickerAdapter

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

import android.app.Activity
import android.support.v7.widget.RecyclerView
import android.view.ViewGroup
import android.widget.{Toast, CompoundButton}
import sword.langbook.android.R
import sword.langbook.android.viewholders._

import scala.collection.mutable

case class ConceptPickerAdapter(activity: Activity, concepts: Seq[String]) extends RecyclerView.Adapter[BaseViewHolder] with CompoundButton.OnCheckedChangeListener {
  val descriptionHeaderText = activity.getString(R.string.conceptPickerDescriptionHeader)
  override val getItemCount = concepts.size + 1

  private val _selected = {
    val result = mutable.BitSet()
    for (index <- concepts.indices) result += index
    result
  }

  def selected = _selected.toSet

  override def getItemViewType(position: Int) = {
    if (position == 0) BaseViewHolder.types.descriptionHeader
    else BaseViewHolder.types.checkableEntry
  }

  override def onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): BaseViewHolder = {
    viewType match {
      case BaseViewHolder.types.`descriptionHeader` => DescriptionHeaderViewHolder.newInstance(viewGroup)
      case BaseViewHolder.types.`checkableEntry` => CheckableEntryViewHolder.newInstance(viewGroup)
    }
  }

  override def onBindViewHolder(vh: BaseViewHolder, position: Int): Unit = {
    vh match {
      case holder: DescriptionHeaderViewHolder =>
        holder.textView.setText(descriptionHeaderText)

      case holder: CheckableEntryViewHolder =>
        holder.textView.setText(concepts(position - 1))

        val checkBox = holder.checkBox
        checkBox.setTag(position - 1)
        checkBox.setChecked(_selected(position - 1))
        checkBox.setOnCheckedChangeListener(this)
    }
  }

  override def onCheckedChanged(buttonView: CompoundButton, isChecked: Boolean): Unit = {
    val index = buttonView.getTag.asInstanceOf[Int]
    if (isChecked) _selected += index
    else _selected -= index
  }
} 
开发者ID:carlos-sancho-ramirez,项目名称:android-scala-langbook,代码行数:57,代码来源:ConceptPickerAdapter.scala


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala PersistenceQuery类代码示例发布时间:2022-05-23
下一篇:
Scala ConfigObject类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap