We have a custom view that extends android.widget.ProgressBar. Our progress bar is not touchable, focusable, etc.: it just shows progress. Style for our custom progress bar extends
“Widget.AppCompat.ProgressBar.Horizontal”. An item, named “progressDrawable”, in our style, is a xml file . What we usually can see as a main single element in this xml file:
Custom views and directional controller clicks. On most devices, clicking a view using a directional controller sends (to the view currently in focus) a KeyEvent with:
Move the major components of the Android platform to correct places in diagram.
Building your app from the command line, if you have a "demo" product flavor, then you can build the debug version with the command:
In general, you should send an AccessibilityEvent whenever the content of your custom view changes. For example, if you are implementing a custom slider bar that allows a user to select a numeric value by pressing the left or right arrows, your custom view should emit an event of type TYPE_VIEW_TEXT_CHANGED whenever the slider value changes. Which one of the following sample codes demonstrates the use of the sendAccessibilityEvent() method to report this event.
Custom views and directional controller clicks. In general, you should send an AccessibilityEvent whenever the content of your custom view changes. For example, if a text value was changed in your custom view, you should emit an event of this type:
Custom duration in milliseconds as a parameter for the setDuration method is available when you are working with:
Working with Custom View. Once you define the custom attributes, you can use them in layout XML files just like built-in attributes. The only difference is that your custom attributes belong to a different namespace. Instead of belonging to the http://schemas.android.com/apk/res/android namespace, they belong to:
For example, we have a file in our assets folder app/src/main/assets/sample_teas.json. To get an
InputStream for reading it, from out Context context, we can try doing this:
In a class PreferenceFragmentCompat. As a convenience, this fragment implements a click listener for any preference in the current hierarchy. So, in what overridden method we can handle that a preference in the tree rooted at this PreferenceScreen has been clicked?
What is demonstrated by the code below?
// RawDao.kt
@Dao
interface RawDao {
@RawQuery
fun getUserViaQuery(query: SupportSQLiteQuery?): User?
}
// Usage of RawDao
...
val query =
SimpleSQLiteQuery("SELECT * FROM User WHERE id = ? LIMIT 1",
arrayOf
val user = rawDao.getUserViaQuery(query)
...
What statements about InputStreamReader (java.io.InputStreamReader) are correct? (Choose two.)
An example. In our ViewModelFactory (that implements ViewModelProvider.Factory) we have an instance of our Repository, named mRepository. Our ViewModel has such constructor:
class MyViewModel(private val mRepository: MyRepository) : ViewModel() ...
Next, in our ViewModelFactory create ViewModel method (overriden) looks like this:
override fun
return try {
//MISSED RETURN VALUE HERE”
} catch (e: InstantiationException) {
throw RuntimeException("Cannot create an instance of $modelClass", e)
} catch (e: IllegalAccessException) {
throw RuntimeException("Cannot create an instance of $modelClass", e)
} catch (e: NoSuchMethodException) {
throw RuntimeException("Cannot create an instance of $modelClass", e)
} catch (e: InvocationTargetException) {
throw RuntimeException("Cannot create an instance of $modelClass", e)
}
}
What should we write instead of “//MISSED RETURN VALUE HERE”?
In our TeaViewModel class, that extends ViewModel, we have such prorerty:
val tea: LiveData
An observer in our Activity (type of mViewModel variable in example is TeaViewModel) is set in this way:
mViewModel!!.tea.observe(this, Observer { tea: Tea? -> displayTea(tea) })
What will be a correct displayTea method definition?
What is the incorrect statement about Data Access Object (androidx.room.Dao)?
Enable debugging on your device: If you are using the emulator, this is enabled by default. But for a connected device, you need to
Once your test has obtained a UiObject object, you can call the methods in the UiObject class to perform user interactions on the UI component represented by that object. You can specify such actions as: (Choose four.)
What happens when you create a DAO method and annotate it with @Insert?
Example:
@Dao
interface MyDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertUsers(vararg users: User)
}