• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/93

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

93 Cards in this Set

  • Front
  • Back
How to instantiate an ImageView in Activity's onCreate() method using Linear Layout class? And set the imageView bounds to match the Drawable's dimention
mLinearLayout = new LinearLayout(this);
ImageView i = new ImageView(this);
i.setImageResource(R.drawable.my_image);
i.setAdjustViewBounds(true);
i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));

// Add the ImageView to the layout and set the layout as the content view
mLinearLayout.addView(i);
What are the 2 ways to use a resource image?
1) use ImageView.setImageResource(R.drawable.my_image)

2) handle image resource as a Drawable object-
Resources res = mContext.getResources();
Drawable myImage = res.getDrawable(R.drawable.my_image);
If you plan on reading an image as a bit stream in order to convert it to a bitmap, where should you put your images?
in the res/raw/ folder instead, where they will not be optimized.
What will happen to Image resources placed in res/drawable/ ?
aapt tool will automatically optimized it with lossless image compression during the build process.
Write a TransitionDrawable xml for "image_expand.png" and "image_collapse.png"
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/image_expand">
<item android:drawable="@drawable/image_collapse">
</transition>
How to nstantiate the TransitionDrawable and set it as the content of an ImageView:
Resources res = mContext.getResources();
TransitionDrawable transition = (TransitionDrawable)
res.getDrawable(R.drawable.expand_collapse);
ImageView image = (ImageView) findViewById(R.id.toggle_image);
image.setImageDrawable(transition);
How to start a transition (name "transition") can be run forward (for 1 second):
transition.startTransition(1000);
How can a client find the preferred size for some Drawables?
the getIntrinsicHeight() and getIntrinsicWidth() methods.
Can Drawable receive events or interact with the user?
NO.
Unlike a View, a Drawable does not have any facility to receive events or otherwise interact with the user.
How can an Animation Drawable know how to call back to it's client?
setCallback(Drawable.Callback))
What Interface you need to Implement if you want to create an animated drawable that extends Drawable.
Drawable.Callback
True of False ? If you set a background drawable for a View, then the View will draw it for you before calling back to its onDraw() method?
True
Drawing is handled by walking the tree and rendering each view that intersects the invalid region. Because the tree is traversed in-order, this means that parents will draw before (i.e., behind) their children, with siblings drawn in the order they appear in the tree. If you set a background drawable for a View, then the View will draw it for you before calling back to its onDraw() method.
Which region of view the framework will not draw?
The framework will not draw views that are not in the "invalid region".
How to make a view redraw itself?
Call Invalidate().
Invalidate the whole view.
What method will be called once a view is being invalidated if the view is visible?
onDraw(android.graphics.Canvas).
It will be called at some point in the future.
This must be called from a UI thread.
Can invalidate() be called from a non-UI thread?
No.
This must be called from a UI thread.
How to call invalidate from a non-UI thread?
postInvalidate().
Cause an invalidate to happen on a subsequent cycle through the event loop. Use this to invalidate the View from a non-UI thread.
How to align a button to the bottom of the parent container?
android:layout_alignParentBottom="true"
What property to use to tell user about the view that doesn't have a textural interface such as image button.
android:contentDescription="@string/app_name"
Define a style.xml "AppBaseTheme" that extends "android:Theme.Light".
<resources>
<style name="AppBaseTheme" parent="android:Theme.Light">
</resources>
Define a dimension object "activity_horizontal_margin" in dimens.xml that is 16dp.
<resources>
<dimen name="activity_horizontal_margin">16dp</dimen>
</resources>
What is an interpolator?
An interpolator defines the rate of change of an animation.

This allows the basic animation effects (alpha, scale, translate, rotate) to be accelerated, decelerated, repeated, etc.
What is interface does the AccelerateDecelerateInterpolator class inherites from?
1) parent - interpolator Interface
2) grandparnet - timeInterpolator Interface
How to use a non-default interpolator ?
setInterpolator (TimeInterpolator value).

if value is null, it will be a linear interpolation.
How to have valueAniamtor instance listens to every updates on every anitmation frame?
valueAnimator.addUpdateListener(new AnimatorUpdateListener(){
 	@Override
			public void onAnimationUpdate(ValueAnimator animation) {		imageView.setBackgroundColor((Integer) animation.getAnimatedValue());
}
})
valueAnimator.addUpdateListener(new AnimatorUpdateListener(){
@Override
public void onAnimationUpdate(ValueAnimator animation) { imageView.setBackgroundColor((Integer) animation.getAnimatedValue());
}
})
Explain what can an implementor of the interface "ValueAnimator.AnimatorUpdateListener" do?
Implementors of this interface can add themselves as update listeners to an ValueAnimator instance to receive callbacks on every animation frame, after the current frame's values have been calculated for that ValueAnimator.
How to get the updated value from the valueAnimator in the onAnimatorUpdate callback on every frame : onAnimationUpdate(ValueAnimator animation)?
animation.getAnimatedValue()
What interface must be implemented by all classes that wish to support cloning?
Clonable
What is a field?
Simple explanation: A field is an attribute.

Say, you have a class called Student. Think of all the characteristics of this student. Name, Date of Birth, School Name, Student Id etc. Each of this attribute will be a "field" in the class definition. That is the answer for your question.
Additional information: Almost always define fields as private (unless there is a real good reason) and provide accessors (or simply put methods) to set the value or retrieve the value eg: getStudentId() or setStudentId(int newStudentId)
What does it mean when we use :
new Interface() means?
You can not instantiate the interface, but you can instantiate an implementation of it. It's an anonymous implementation.

you are creating a brand new class that is an anonymous inner class and which inherit (implements) the interface.

It is called an anonymous inner class because it not has a name of its own and it can therefore not be instantiated explicitly without going through the method testMethod() and it can only be referenced through an reference variable with the type Interface.
How to animate color object?
ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), RED, BLUE);

// Definition.
public static ValueAnimator ofObject(TypeEvaluator evaluator, Object... values) {
What does a TypeEvaluator do for the targets in an animation.
A TypeEvaluator that will be called on each animation frame to
* provide the ncessry interpolation between the Object values to derive the animated
* value.
How to assign top padding using a property value >
android:paddingTop="@dimen/activity_vertical_margin"
Which are the two types animations an animation resource can define?
1) Property Animation :
Creates an animation by modifying an object's property values over a set period of time with an Animator.

2) View Animation:
a) Tween animation: Creates an animation by performing a series of transformations on a single image with an "Animation".

b) Frame animation: creates an animation by showing a sequence of images in order with an AnimationDrawable.
What is an Animator object?
This is the superclass for classes which provide basic support for animations which can be
1) started,
2) ended,
3) and have AnimatorListeners added to them.
What are the different value types in ValueAnimator's value type property?
android:valueType =
1) intType
2) floatType

The animation framework automatically handles color values.
What is the required attributes in <objectAnimator>?
1) android:propertyName = "alpha" or "backgroundColor"

2) valueTo:
float, int, or color. Required. The value where the animated property ends. Colors are represented as six digit hexadecimal numbers (for example, #333333).
How to set the target object to animate using the object animator whos' property is defined in the android:propertyName inside the objectAnimator tag in the the animation xml"?
1) Inflate your animation xml resource by calling loadAnimator() 

2) then, call setTarget() to set the target object that contains this property.
1) Inflate your animation xml resource by calling loadAnimator()

2) then, call setTarget() to set the target object that contains this property.
What is the xml syntax for an AnimatorSet ?
<set
android:ordering=["together" | "sequentially"]>
What is an animator's file location?
res/animator/property_animator.xml:
The filename will be used as the resource ID.
What is an animator's resource reference in JAVA?
R.animator.property_animator
What is an animator's resource reference in XML?
@[package:]animator/property_animator
What does this mean : android:valueTo="1f" ?
toFind
What is the Animation class?
Abstraction for an Animation that can be applied to Views, Surfaces, or other objects.
Android provides two mechanisms that you can use to create simple animations. What are they?
1) tweened animation : in which you tell Android to perform a series of simple transformations (position, size, rotation, and so on) to the content of a View;

2) and frame-by-frame animation: which loads a series of Drawable resources one after the other.
What can a tweened animation perform on?
to the content of a View.
How does android perform in the frame-by-frame animation?
it loads a series of Drawable resources one after another.
Who handles a tweened animation?
the package (android.view.animation);
Who handles a frame-by-frame animation?
AnimationDrawable class
What are the steps in adding a fragment to an activity?
1) Get reference to the Fragment Manager
2) Begin a fragment transaction
3) Add the fragment
4) Commit the fragment Transaction.
How to make sure that the fragments won't get destroyed on configuration changed?
Use setRetainInstance(true)
Which lifecycle callbacks won't get called on fragment?
1) onDestroy()
2) onCreate()
How to make sure the old fragment will be saved when returning?
addToBackStack(null)
How to inflate a layout from a View?
view.getLayoutInflator()
How to inflate a layout using service?
getSystemService(LayoutInflator)
Which method must be called to tell the Drawable where it is drawn and how large it should be?
setBounds(Rect)
How can a client find the preferred size for some Drawables ?
getIntrinsicHeight() and getIntrinsicWidth() methods
How to know Drawables information about how to frame content that is placed inside of them.
getPadding(Rect)
Which method allows the client to tell the Drawable in which state it is to be drawn, such as "focused", "selected"?
setState(int[])
Some drawables may modify their imagery based on the selected state.
Which method allows the client to supply a single continuous controller that can modify the Drawable is displayed, such as a battery level or progress level?
setLevel(int)
How can a Drawable call back to its client to perform animations ?
Call Drawable.Callback interface.
Which interface the client should support so that animations will work.
via setCallback(Drawable.Callback)
What are the simple way to do setCallback(Drawable.Callback) through the system facilities?
setBackgroundDrawable(Drawable) and ImageView.
What is a ShapeDrawable?
A Drawable object that draws primitive shapes. A ShapeDrawable takes a Shape object and manages its presence on the screen. If no Shape is given, then the ShapeDrawable will default to a RectShape.
What is a ClipDrawable?
A Drawable that clips another Drawable based on this Drawable's current level value. You can control how much the child Drawable gets clipped in width and height based on the level, as well as a gravity to control where it is placed in its overall container. Most often used to implement things like progress bars, by increasing the drawable's level with setLevel().
How to hide a child Drawable with ClipDrawable?
setLevel(0)
How to 100% show a child Drawable with ClipDrawable?
setLevel(10000)
How to use progress or volume level to very a ClipDrawable's imagery?
1) use setLevel(int level)
.
If the new level you are supplying in setLevel() causes the appearance of the Drawable to change, then it is responsible for calling which method in order to have itself redrawn?
invalidateSelf()
What does it mean when the return value from the setLevel() is true ?
This change in level has caused the appearance of the Drawable to change (hence requiring an invalidate), otherwise returns false.
What is one way we can set the state of the Drawable in a Button?
setState ( [state_focused, state_pressed])
How to force a Drawable to behave as if it has just become visible.
setVisible(bVisible, bRestart=true)
How to have the Drawable unscheduled using the current Drawable.Callback?
unscheduleSelf (Runnable what)
what The runnable that you no longer want called.
How can a Drawable schedule the next frame of it's animation?
Drawable.Callback().scheduleDrawable (Drawable who, Runnable what, long when).

An implementation can generally simply call
"postAtTime(Runnable, Object, long)" with the parameters (what, who, when) to perform the scheduling.
What is wrong with this code:
public abstract boolean isChanged() {
return smt else...
}
abstract methods cannot have a body.
abstract methods cannot have a body.
How can a Drawable unschedule an action previously scheduled with scheduleDrawable(Drawable, Runnable, long).
An implementation can generally simply call removeCallbacks(Runnable, Object) with the parameters (what, who) to unschedule the drawable.
Which method is called when the drawable needs to be redrawn?
invalidateDrawable (Drawable who)

A view at this point should invalidate itself (or at least the part of itself where the drawable appears).
Which type of Drawable manages an array of other Drawables.
LayerDrawable

These are drawn in array order, so the element with the largest index will be drawn on top.
What are the xml tags used to represent LayerDrawable?
<layer-list>
<item/>
<item/>
</layer-list>
Which Drawable is used to cross-fade between the first and second layer?
TransitionDrawable
How to tell TransitionDrawable to start the transition?
call startTransition(int).
How to tell TransitionDrawable to display just the first layer,
call resetTransition().
Which type of Drawable lets you assign a number of graphic images to a single Drawable and swap out the visible item by a string ID value?
StateListDrawable
What are the xml tags used to represent StateListDrawable?
<selector>
<item/>
<item/>
</selector>
What type of Drawable manages a number of alternate Drawables, each assigned a maximum numerical value. Setting the level value of the object with setLevel(int) will load the image with the next greater or equal value assigned to its max attribute?
LevelListDrawable
What are the xml tags used to represent LevelListDrawable?
<level-list>
<item android:maxLevel="0" android:drawable="@drawable/ic_wifi_signal_1" />

<item/>
</level-list>
Where should a <level-list> drawable be saved so that a ImageView can reference it as a drawable?
res/drawable/ folder
A <level-list> drawable xml was saved in res/drawable/ folder and is ready to be referenced by an ImageView. How will the imageView change it's default image to one of the other levels?
Use setImageLevel(int).
What type of Drawable which can be used to create frame-by-frame animations, defined by a series of Drawable objects, which can be used as a View object's background.
AnimationDrawable
What is the simpliest way to create a frame-by-frame animation?
1) define the animation in an XML file,
2) placed in the res/drawable/ folder,
3) and set it as the background to a View object.
4) Then, call start() on the AnimationDrawable to run the animation.
What are the xml tags used to represent AnimationDrawable?
<animation-list>
<item android:drawable="@drawable/wheel0" android:duration="50" />
<item android:drawable="@drawable/wheel1" android:duration="50" />

</animation-list>
How to set a background animation on an ImageView?
img.setBackgroundResource(R.drawable.spin_animation);
How to start a background animation?
// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
// Start the animation (looped playback by default).
frameAnimation.start();