Free Associate Android Developer Exam Braindumps

The easiest way of adding menu items (to specify the options menu for an activity) is inflating an XML file into the Menu via MenuInflater. With menu_main.xml we can do it in this way:

  1. override fun onCreateOptionsMenu(menu: Menu): Boolean {
    menuInflater.inflate(R.menu.menu_main, menu)
    return true
    }
  2. override fun onOptionsItemSelected(item: MenuItem): Boolean {
    menuInflater.inflate(R.menu.menu_main, menu)
    return super.onOptionsItemSelected(item)
    }
  3. override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.menu.menu_main)
    }

Answer(s): A


Reference:

https://developer.android.com/guide/topics/ui/accessibility/custom-views



Android Tests. You can use the childSelector() method to nest multiple UiSelector instances. For example, the following code example shows how your test might specify a search to find the first ListView in the currently displayed UI, then search within that ListView to find a UI element with the text property Apps. What is the correct sample?

  1. val appItem: UiObject = device.findObject(
    UiSelector().className(ListView.class)
    .instance(1)
    .childSelector(
    UiSelector().text("Apps")
    )
    )
  2. val appItem: UiObject = device.findObject(
    UiSelector().className("android.widget.ListView")
    .instance(0)
    .childSelector(
    UiSelector().text("Apps")
    )
    )
  3. val appItem: UiObject = device.findObject(
    UiSelector().className("android.widget.ListView")
    .instance(
    UiSelector().text("Apps")
    )
    )

Answer(s): B



The following code snippet shows an example of an Espresso test:

  1. @Rule
    fun greeterSaysHello() {
    onView(withId(R.id.name_field)).do(typeText("Steve"))
    onView(withId(R.id.greet_button)).do(click())
    onView(withText("Hello Steve!")).check(matches(isDisplayed()))
    }
  2. @Test
    fun greeterSaysHello() {
    onView(withId(R.id.name_field)).perform(typeText("Steve"))
    onView(withId(R.id.greet_button)).perform(click())
    onView(withText("Hello Steve!")).check(matches(isDisplayed()))
    }
  3. @Test
    fun greeterSaysHello() {
    onView(withId(R.id.name_field)).do(typeText("Steve"))
    onView(withId(R.id.greet_button)).do(click())
    onView(withText("Hello Steve!")).compare(matches(isDisplayed()))
    }

Answer(s): B



As an example. In an Activity we have our TimerViewModel object (extended ViewModel), named
mTimerViewModel. mTimerViewModel.timer method returns a LiveData<Long> value.

What can be a correct way to set an observer to change UI in case if data was changed?

  1. mTimerViewModel!!.timer.value.toString().observe
    (Observer { aLong -> callAnyChangeUIMethodHere(aLong!!) })
  2. mTimerViewModel!!.timer.observe
    (this, Observer { aLong -> callAnyChangeUIMethodHere(aLong!!) })
  3. mTimerViewModel.observe
    (Observer { aLong -> callAnyChangeUIMethodHere(aLong!!) })

Answer(s): B






Post your Comments and Discuss Google Associate Android Developer exam with other Community members:

Associate Android Developer Exam Discussions & Posts