本文整理匯總了Java中android.graphics.drawable.StateListDrawable.getCurrent方法的典型用法代碼示例。如果您正苦於以下問題:Java StateListDrawable.getCurrent方法的具體用法?Java StateListDrawable.getCurrent怎麽用?Java StateListDrawable.getCurrent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.StateListDrawable
的用法示例。
在下文中一共展示了StateListDrawable.getCurrent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testCreateStateList
import android.graphics.drawable.StateListDrawable; //導入方法依賴的package包/類
/**
* Tests the {@link Coloring#createStateList(Context, int, int, int, boolean, int)} method.
* <p>
* Unfortunately {@link StateListDrawable#getCurrent()} is not shadowed by Robolectric yet.
*/
@Test
public final void testCreateStateList() {
final int colorNormal = Color.WHITE;
final int colorActive = Color.GRAY;
final int colorFocused = Color.YELLOW;
final StateListDrawable drawable = Coloring.createStateList(mActivityContext, colorNormal, colorActive, colorFocused, true, 0);
assertNotNull("StateListDrawable is null", drawable);
drawable.setState(new int[] {});
assertTrue("StateListDrawable is not stateful", drawable.isStateful());
final Drawable.ConstantState constantState = drawable.getConstantState();
assertNotNull("Constant state is null", constantState);
final Drawable currentState = drawable.getCurrent();
assertNull("Robolectric started shadowing current state", currentState);
}