This commit is contained in:
hyb1996
2017-04-26 13:48:59 +08:00
parent 38fa3b3988
commit 6829c0659e
92 changed files with 3439 additions and 679 deletions

View File

@@ -1,63 +0,0 @@
package com.stardust.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
/**
* Created by Stardust on 2017/3/11.
*/
public class ViewSwitcher extends android.widget.ViewSwitcher {
private View mCurrentView;
public ViewSwitcher(Context context) {
super(context);
}
public ViewSwitcher(Context context, View first, View second) {
super(context);
addView(first);
addView(second);
}
public ViewSwitcher(Context context, AttributeSet attrs) {
super(context, attrs);
}
public View getCurrentView() {
return mCurrentView;
}
public int getCurrentViewIndex() {
return mCurrentView == getChildAt(0) ? 0 : 1;
}
public void showFirst() {
ensureCurrentView();
if (mCurrentView != getChildAt(0)) {
showPrevious();
mCurrentView = getChildAt(0);
}
}
private void ensureCurrentView() {
if (mCurrentView == null) {
mCurrentView = getChildAt(0);
}
}
public void showSecond() {
ensureCurrentView();
if (mCurrentView != getChildAt(1)) {
showNext();
mCurrentView = getChildAt(1);
}
}
public void setSecondView(View v) {
removeViewAt(1);
addView(v);
}
}