下面列出了怎么用android.widget.ViewSwitcher的API类实例代码及写法,或者点击链接到github查看源代码。
public void initViews() {
flRootView = (FrameLayout) activity.findViewById(R.id.play_root);
isBg = (ImageSwitcher) activity.findViewById(R.id.play_bg);
isBg.setFactory(new ViewSwitcher.ViewFactory() {
@Override
public View makeView() {
ImageView view = new ImageView(activity);
view.setLayoutParams(new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT));
view.setScaleType(ImageView.ScaleType.CENTER_CROP);
return view;
}
});
}
private void initViews() {
albumView = (ImageSwitcher) view.findViewById(R.id.play_album_is);
albumView.setFactory(new ViewSwitcher.ViewFactory() {
@Override
public View makeView() {
ImageView imageView = new ImageView(getActivity());
imageView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
int pad = (int) getActivity().getResources().getDimension(R.dimen.play_album_padding);
imageView.setPadding(pad, pad, pad, pad);
return imageView;
}
});
DisplayMetrics metrics = Utils.getMetrics(getActivity());
//专辑图片直径
int size = metrics.widthPixels * 2 / 3;
albumPictureController = new AlbumPictureController(getActivity(), albumView, size);
}
public PinView(Context context, PinListener listener, String pin, int layoutId) {
this.context = context;
this.listener = listener;
this.confirmPin = pin == null;
this.pin1 = pin;
LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = layoutInflater.inflate(layoutId, null);
for (int id : buttons) {
v.findViewById(id).setOnClickListener(this);
}
result = (TextView)v.findViewById(R.id.result1);
switcher = (ViewSwitcher)v.findViewById(R.id.switcher);
switcher.setInAnimation(inFromRightAnimation());
switcher.setOutAnimation(outToLeftAnimation());
try {
digest = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
this.vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
}
@Override
protected void initViews(Bundle savedInstanceState) {
setDisplayHomeAsUpEnabled(true);
tvVersion = findViewById(R.id.tv_app_version);
tvVersion.setText("v" + BuildConfig.VERSION_NAME);
imageSwitcher = findViewById(R.id.imageSwitcher);
imageSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
@Override
public View makeView() {
ImageView imageView = new ImageView(AboutActivity.this);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
return imageView;
}
});
imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,
R.anim.zoom_in));
imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,
R.anim.zoom_out));
}
/**
* Hides the Options Menu and uses a ViewSwitcher to quick turn the exisiting TextView with the
* Flow's name into an EditText for the user to rename.
*
* @param cardPosition position of cardview in adapter
* @param cardViewClicked the cardview view object clicked
*/
private void renameFlow(final int cardPosition, final View cardViewClicked) {
menuState = AppConstants.MENU_ITEMS_HIDE;
invalidateOptionsMenu();
final ViewSwitcher switcher = (ViewSwitcher) cardViewClicked.findViewById(R.id.hub_rename_switcher);
final EditText rename = (EditText) switcher.findViewById(R.id.hub_item_flow_rename);
AppUtils.setNameInputFilters(rename);
rename.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (rename.hasFocus()) {
showEditPopupWindow(rename, cardViewClicked, switcher, cardPosition);
}
}
});
switcher.showNext();
rename.requestFocus();
/* Forces keyboard */
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
root = (ViewSwitcher) inflater.inflate(R.layout.fragment_network,
container, false);
messages = (TextView) root.findViewById(R.id.loading_text);
final View autoConnect = root.findViewById(R.id.auto_connect);
// Auto connect service unavailable for manual calculations
if (wifiNetwork.getScanResult() == null)
autoConnect.setVisibility(View.GONE);
else {
final int level = wifiNetwork.getLevel();
}
if (passwordList != null)
displayResults();
return root;
}
@Override protected void initView() {
getWindow().addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
getWindow().addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
setUI();
SwipeUnLockLayout swipeUnLockLayout = (SwipeUnLockLayout) findViewById(
R.id.slide_layout);
swipeUnLockLayout.setOnSwipeListener(this);
mViewSwitcher = (ViewSwitcher) findViewById(R.id.lock_view_switcher);
mTitle = (TextView) findViewById(R.id.lock_view_gank_title);
TextView mLockViewDate = (TextView) findViewById(R.id.lock_view_date);
final String lockDateText = DateUtil.getLockDateText();
mLockViewDate.setText(lockDateText);
mImg = (ImageView) findViewById(R.id.lock_view_img);
url = PreferenceUtil.getString("url");
if (url.isEmpty()) {
mImg.setImageResource(R.drawable.test_image);
} else {
getBitmap();
}
mImg.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
mViewSwitcher.showNext();
}
});
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome_to_summoner_rift);
ButterKnife.bind(this);
mProcessTv.setInAnimation(this, R.anim.bottom_in);
mProcessTv.setOutAnimation(this, R.anim.top_out);
mProcessTv.setFactory(new ViewSwitcher.ViewFactory() {
@Override
public TextView makeView() {
TextView textView = (TextView) LayoutInflater.from(WelcomeToSummonerRift.this)
.inflate(R.layout.progress_text, null);
return textView;
}
});
}
@Test
public void onActivityResult_vaultedPaymentEditedReturnsToDropIn() {
setup(mock(BraintreeFragment.class));
PayPalAccountNonce paypalNonce = mock(PayPalAccountNonce.class);
when(paypalNonce.getDescription()).thenReturn("paypal-nonce");
ArrayList<Parcelable> paymentMethodNonces = new ArrayList<Parcelable>();
paymentMethodNonces.add(paypalNonce);
assertEquals(0, ((ViewSwitcher) mActivity.findViewById(R.id.bt_loading_view_switcher)).getDisplayedChild());
mActivity.onActivityResult(DELETE_PAYMENT_METHOD_NONCE_CODE, RESULT_OK, new Intent()
.putExtra("com.braintreepayments.api.EXTRA_PAYMENT_METHOD_NONCES", paymentMethodNonces));
assertEquals(1, ((ViewSwitcher) mActivity.findViewById(R.id.bt_loading_view_switcher)).getDisplayedChild());
}
@Test
public void configurationChangeReturnsToEditCardView() {
BraintreeUnitTestHttpClient httpClient = new BraintreeUnitTestHttpClient()
.configuration(new TestConfigurationBuilder()
.creditCards(getSupportedCardConfiguration())
.build());
setup(httpClient);
setText(mAddCardView, R.id.bt_card_form_card_number, VISA);
assertThat(mEditCardView).isVisible();
assertThat(mAddCardView).isGone();
assertEquals(1, ((ViewSwitcher) mActivity.findViewById(R.id.bt_loading_view_switcher))
.getDisplayedChild());
assertThat(mEnrollmentCardView).isGone();
triggerConfigurationChange(httpClient);
assertThat(mEditCardView).isVisible();
assertThat(mAddCardView).isGone();
assertEquals(1, ((ViewSwitcher) mActivity.findViewById(R.id.bt_loading_view_switcher))
.getDisplayedChild());
assertThat(mEnrollmentCardView).isGone();
}
@Test
public void addingACardRemainsOnEditCardView() {
setup(new BraintreeUnitTestHttpClient().configuration(new TestConfigurationBuilder()
.creditCards(getSupportedCardConfiguration())
.build()));
setText(mAddCardView, R.id.bt_card_form_card_number, VISA);
mAddCardView.findViewById(R.id.bt_button).performClick();
setText(mEditCardView, R.id.bt_card_form_expiration, ExpirationDate.VALID_EXPIRATION);
mEditCardView.findViewById(R.id.bt_button).performClick();
assertThat(mEditCardView).isVisible();
assertThat(mEditCardView.findViewById(R.id.bt_animated_button_loading_indicator)).isVisible();
assertThat(mEditCardView.findViewById(R.id.bt_button)).isGone();
assertEquals(1, ((ViewSwitcher) mActivity.findViewById(R.id.bt_loading_view_switcher))
.getDisplayedChild());
assertThat(mAddCardView).isGone();
assertThat(mEnrollmentCardView).isGone();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageSwitcher = findViewById(R.id.is);
imageSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
@Override
public View makeView() {
ImageView iv = new ImageView(MainActivity.this);
iv.setScaleType(ImageView.ScaleType.CENTER);//居中显示
//ViewSwitcher 默认给子控件设置match parent,所以此处不设置LayoutParams
Log.d("realmo","make View"); //从源码得知,会触发2次(ViewSwitcher : only two child views)
return iv;
}
});
imageSwitcher.setImageResource(resIds[index]);//初始化时显示,必须放在工厂后面,否则会报NullPointerException
imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));//设置动画
imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));//设置动画
}
private void initViews(Context context) {
//与梦想列表同布局
inflate(context, R.layout.common_empty_xlistview_layout, this);
llContainerView = (LinearLayout)findViewById(R.id.ll_contaner_view);
vsLayout = (ViewSwitcher)findViewById(R.id.vs_view_switcher);
emptyLayout = (EmptyLayout)findViewById(R.id.empty_layout_4_loading);
emptyLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
emptyLayout.setErrorType(EmptyLayout.NETWORK_LOADING);
onRefresh();
}
});
xListView = (XListView) findViewById(R.id.activity_searchfriends_data_listview);
xListView.setXListViewListener(this);
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
if (isNewInstance()) {
mFragmentView = inflater.inflate(R.layout.fragment_web, container, false);
mFullscreenView = (ViewGroup) mFragmentView.findViewById(R.id.fullscreen);
mScrollViewContent = (ViewGroup) mFragmentView.findViewById(R.id.scroll_view_content);
mScrollView = (NestedScrollView) mFragmentView.findViewById(R.id.nested_scroll_view);
mControls = (ViewSwitcher) mFragmentView.findViewById(R.id.control_switcher);
mWebView = (WebView) mFragmentView.findViewById(R.id.web_view);
mButtonRefresh = (ImageButton) mFragmentView.findViewById(R.id.button_refresh);
mButtonMore = mFragmentView.findViewById(R.id.button_more);
mButtonNext = mFragmentView.findViewById(R.id.button_next);
mButtonNext.setEnabled(false);
mEditText = (EditText) mFragmentView.findViewById(R.id.edittext);
setUpWebControls(mFragmentView);
setUpWebView(mFragmentView);
}
return mFragmentView;
}
private void initViews() {
board = (ViewSwitcher) findViewById(R.id.switcher);
Typeface tf = ThisApplication.getFontResource(R.string.font_oem1);
TextView tv = (TextView) findViewById(R.id.txtAppName);
tv.setTypeface(tf);
tf = ThisApplication.getFontResource(R.string.font_oem2);
tv = getFrontPage();
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setTypeface(tf);
tv = getBackPage();
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setTypeface(tf);
toolbar = new Toolbar((ViewGroup) findViewById(R.id.toolbar));
}
private void initViews() {
board = (ViewSwitcher) findViewById(R.id.switcher);
Typeface tf = ThisApplication.getFontResource(R.string.font_oem1);
TextView tv = (TextView) findViewById(R.id.txtAppName);
tv.setTypeface(tf);
tf = ThisApplication.getFontResource(R.string.font_oem2);
tv = getFrontPage();
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setTypeface(tf);
tv = getBackPage();
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setTypeface(tf);
toolbar = new Toolbar((ViewGroup) findViewById(R.id.toolbar));
}
private void updateAnimation() {
View view = getView();
if (view == null) {
return;
}
ViewSwitcher viewSwitcher = (ViewSwitcher) view;
if (viewSwitcher.getInAnimation() != mInAnimation || mInAnimation == null) {
if (mInAnimation == null) {
mInAnimation = AnimationFactory.pushDownIn();
}
if (viewSwitcher instanceof TextSwitcher) {
mInAnimation.setAnimationListener(mTextViewInAnimationListener);
}
mInAnimation.setDuration(mInDuration);
viewSwitcher.setInAnimation(mInAnimation);
}
if (viewSwitcher.getOutAnimation() != mOutAnimation || mOutAnimation == null) {
if (mOutAnimation == null) {
mOutAnimation = AnimationFactory.pushDownOut();
}
mOutAnimation.setDuration(mOutDuration);
viewSwitcher.setOutAnimation(mOutAnimation);
}
}
@Override
protected void bindItemView(View convertView, Context context, Cursor cursor) {
final ToasterModel toaster = new ToasterModel();
toaster.loadFromCursor(cursor);
final ViewHolder holder = (ViewHolder) convertView.getTag();
holder.txtName.setText(toaster.name);
holder.txtJob.setText(toaster.jobDescription);
Picasso.with(context).load(toaster.imageUrl)
.error(R.drawable.toaster_backup).transform(mToasterTrans)
.into(holder.imgToaster);
Picasso.with(context).load(toaster.imageUrl)
.error(R.drawable.toaster_backup).transform(mHumanTrans)
.into(holder.imgHuman);
// Reseting the view our switcher is showing.
switchWithoutAnimation(holder.switcher);
holder.switcher.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
((ViewSwitcher) v).showNext();
}
});
}
public void setContent(Fragment content) {
Fragment last = mCurrentContent;
mCurrentContent = content;
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
if (last != null)
ft.replace(R.id.content, mCurrentContent);
else
ft.add(R.id.content, mCurrentContent);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
if (mContainer instanceof ViewSwitcher) {
ViewSwitcher switcher = (ViewSwitcher)mContainer;
if (mContent != switcher.getCurrentView())
switcher.showNext();
}
ft.commit();
}
@Override
public void onPreExecute() {
MainActivity activity = (MainActivity) mActivity.get();
((DrawerLayout) activity.drawer).setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
mFragment.get().enablePullToRefresh(true);
activity.findViewById(R.id.refresh_fab).setEnabled(true);
((RefreshIcon) activity.findViewById(R.id.refresh_fab)).show();
activity.invalidateOptionsMenu();
ViewSwitcher viewSwitcher = activity.findViewById(R.id.switcher);
EditText newLyrics = activity.findViewById(R.id.edit_lyrics);
viewSwitcher.setVisibility(View.VISIBLE);
newLyrics.setVisibility(View.GONE);
}
private void setupTitle(){
titleSwitcher.setInAnimation(getAnimation(R.anim.slide_in_to_bottom, true));
titleSwitcher.setOutAnimation(getAnimation(R.anim.slide_out_to_top, false));
titleSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
@Override
public View makeView() {
TextView view = (TextView) getLayoutInflater().inflate(R.layout.view_title, titleSwitcher, false);
if (view != null) {
view.setTextColor(titleTextColor);
}
return view;
}
});
titleSwitcher.setText("");
}
private void setupError(){
errorSwitcher.setInAnimation(getAnimation(android.R.anim.slide_in_left, true));
errorSwitcher.setOutAnimation(getAnimation(android.R.anim.slide_out_right, false));
errorSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
@Override
public View makeView() {
TextView view = (TextView) getLayoutInflater().inflate(R.layout.view_error, titleSwitcher, false);
if (view != null && errorTextColor != -1) {
view.setTextColor(errorTextColor);
}
return view;
}
});
errorSwitcher.setText("");
}
private void setupDetails(){
detailsSwitcher.setInAnimation(getAnimation(R.anim.alpha_in, true));
detailsSwitcher.setOutAnimation(getAnimation(R.anim.alpha_out, false));
detailsSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
@Override
public View makeView() {
TextView view = (TextView) getLayoutInflater().inflate(R.layout.view_details, titleSwitcher, false);
if (view != null && detailsTextColor != -1) {
view.setTextColor(detailsTextColor);
}
return view;
}
});
detailsSwitcher.setText("");
}
private void switchersShowNext() {
ViewSwitcher switcherName = (ViewSwitcher) getView().findViewById(R.id.fragment_se_switcher_name);
ViewSwitcher switcherTime = (ViewSwitcher) getView().findViewById(R.id.fragment_se_switcher_time);
ViewSwitcher switcherNotes = (ViewSwitcher) getView().findViewById(R.id.fragment_se_switcher_notes);
switcherName.showNext();
switcherTime.showNext();
switcherNotes.showNext();
}
public ViewHolder(View view) {
super(view);
card = view;
name = (TextView) view.findViewById(R.id.item_flow_name);
elements = (TextView) view.findViewById(R.id.item_element_count);
timeEstimate = (TextView) view.findViewById(R.id.item_total_time);
rename = (EditText) view.findViewById(R.id.hub_item_flow_rename);
switcher = (ViewSwitcher) view.findViewById(R.id.hub_rename_switcher);
/* Set up views for set operations */
}
public CardViewHolder(CardView itemView) {
super(itemView);
chartView = (ChartView) itemView.findViewById(R.id.chart_view);
sensorSelectionArea = itemView.findViewById(R.id.sensor_selection_area);
sensorTabLayout = (TabLayout) itemView.findViewById(R.id.sensor_selector_tab_layout);
sensorSettingsGear = (ImageButton) itemView.findViewById(R.id.settings_gear);
sensorTabHolder = (ViewGroup) itemView.findViewById(R.id.sensor_selection_tab_holder);
graphStatsList = (StatsList) itemView.findViewById(R.id.stats_drawer);
header = (SensorCardHeader) itemView.findViewById(R.id.sensor_card_header);
headerText = (TextView) itemView.findViewById(R.id.sensor_card_header_title);
toggleButton = (ToggleArrow) itemView.findViewById(R.id.btn_sensor_card_toggle);
toggleButtonSpacer = itemView.findViewById(R.id.sensor_card_toggle_spacer);
menuButton = (ImageButton) itemView.findViewById(R.id.btn_sensor_card_overflow_menu);
graphViewGroup = (ViewGroup) itemView.findViewById(R.id.graph_view_content_group);
meterSensorIconContainer =
(RelativeLayout) itemView.findViewById(R.id.card_meter_sensor_icon_container);
meterLiveData = (SingleLineResizableTextView) itemView.findViewById(R.id.live_sensor_value);
statusViewGroup = (ViewGroup) itemView.findViewById(R.id.status_view_content_group);
statusProgressBar = (ProgressBar) itemView.findViewById(R.id.progress_bar);
statusMessage = (TextView) itemView.findViewById(R.id.status_message);
statusRetryButton = (Button) itemView.findViewById(R.id.status_retry_button);
triggerSection = (RelativeLayout) itemView.findViewById(R.id.sensor_card_trigger_section);
triggerIcon = (ViewSwitcher) itemView.findViewById(R.id.trigger_icon_view_switcher);
triggerLevelDrawableButton = (ImageButton) itemView.findViewById(R.id.sensor_trigger_icon);
triggerTextSwitcher = (TextSwitcher) itemView.findViewById(R.id.trigger_text_switcher);
triggerFiredBackground =
(TriggerBackgroundView) itemView.findViewById(R.id.sensor_trigger_fired_background);
triggerFiredText = (TextView) itemView.findViewById(R.id.trigger_fired_text);
infoButton = (ImageButton) itemView.findViewById(R.id.btn_info);
WindowManager windowManager =
(WindowManager) itemView.getContext().getSystemService(Context.WINDOW_SERVICE);
screenOrientation = windowManager.getDefaultDisplay().getRotation();
}
/**
* Creates an instance of {@link BookmarkManager}. It also initializes resources,
* bookmark models and jni bridges.
* @param activity The activity context to use.
* @param isDialogUi Whether the main bookmarks UI will be shown in a dialog, not a NativePage.
*/
public BookmarkManager(Activity activity, boolean isDialogUi) {
mActivity = activity;
mIsDialogUi = isDialogUi;
mBookmarkModel = new BookmarkModel();
mMainView = (ViewGroup) mActivity.getLayoutInflater().inflate(R.layout.bookmark_main, null);
mDrawer = (DrawerLayout) mMainView.findViewById(R.id.bookmark_drawer_layout);
mDrawerListView = (BookmarkDrawerListView) mMainView.findViewById(
R.id.bookmark_drawer_list);
mContentView = (BookmarkContentView) mMainView.findViewById(R.id.bookmark_content_view);
mViewSwitcher = (ViewSwitcher) mMainView.findViewById(R.id.bookmark_view_switcher);
mUndoController = new BookmarkUndoController(activity, mBookmarkModel,
((SnackbarManageable) activity).getSnackbarManager());
mSearchView = (BookmarkSearchView) getView().findViewById(R.id.bookmark_search_view);
mBookmarkModel.addObserver(mBookmarkModelObserver);
initializeToLoadingState();
mBookmarkModel.runAfterBookmarkModelLoaded(mModelLoadedRunnable);
// Load partner bookmarks explicitly. We load partner bookmarks in the deferred startup
// code, but that might be executed much later. Especially on L, showing loading
// progress bar blocks that so it won't be loaded. http://crbug.com/429383
PartnerBookmarksShim.kickOffReading(activity);
mLargeIconBridge = new LargeIconBridge(Profile.getLastUsedProfile().getOriginalProfile());
ActivityManager activityManager = ((ActivityManager) ContextUtils
.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE));
int maxSize = Math.min(activityManager.getMemoryClass() / 4 * 1024 * 1024,
FAVICON_MAX_CACHE_SIZE_BYTES);
mLargeIconBridge.createCache(maxSize);
}
@Override protected void onFinishInflate() {
super.onFinishInflate();
modifierTitle = (TextView) findViewById(R.id.bike_image_modifier_title);
textSwitcher = (TextSwitcher) findViewById(R.id.text_switcher);
textSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
@Override public View makeView() {
return LayoutInflater.from(getContext()).inflate(R.layout.modifier_value_textview, null);
}
});
}
@Test
public void onPaymentMethodNonceDeleted_removesLoadingView() {
((ViewSwitcher)mActivity.findViewById(R.id.bt_loading_view_switcher)).setDisplayedChild(1);
mActivity.onPaymentMethodNonceDeleted(mCardNonce);
assertEquals(0, ((ViewSwitcher)mActivity
.findViewById(R.id.bt_loading_view_switcher)).getDisplayedChild());
}
@Test
public void onError_whenPaymentMethodDeletedException_removesLoadingView() {
Exception originalException = new RuntimeException("Real Exception");
Exception error = new PaymentMethodDeleteException(mCardNonce, originalException);
((ViewSwitcher)mActivity.findViewById(R.id.bt_loading_view_switcher)).setDisplayedChild(1);
mActivity.onError(error);
assertEquals(0, ((ViewSwitcher)mActivity
.findViewById(R.id.bt_loading_view_switcher)).getDisplayedChild());
}