下面列出了怎么用android.widget.SlidingDrawer的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Sets the status of a given SlidingDrawer. Examples are Solo.CLOSED and Solo.OPENED.
*
* @param slidingDrawer the {@link SlidingDrawer}
* @param status the status that the {@link SlidingDrawer} should be set to
*/
public void setSlidingDrawer(final SlidingDrawer slidingDrawer, final int status){
if(slidingDrawer != null){
Activity activity = activityUtils.getCurrentActivity(false);
if(activity != null){
activity.runOnUiThread(new Runnable()
{
public void run()
{
try{
switch (status) {
case CLOSED:
slidingDrawer.close();
break;
case OPENED:
slidingDrawer.open();
break;
}
}catch (Exception ignored){}
}
});
}
}
}
/**
* Sets the status of a SlidingDrawer matching the specified index. Examples of status are: {@code Solo.CLOSED} and {@code Solo.OPENED}.
*
* @param index the index of the {@link SlidingDrawer}
* @param status the status to set the {@link SlidingDrawer}
*/
public void setSlidingDrawer(int index, int status){
if(config.commandLogging){
Log.d(config.commandLoggingTag, "setSlidingDrawer("+index+", "+status+")");
}
setSlidingDrawer(waiter.waitForAndGetView(index, SlidingDrawer.class), status);
}
public WrappingSlidingDrawer(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
int orientation = attrs
.getAttributeIntValue("android", "orientation", ORIENTATION_VERTICAL);
mTopOffset = attrs.getAttributeIntValue("android", "topOffset", 0);
mVertical = (orientation == SlidingDrawer.ORIENTATION_VERTICAL);
}
public WrappingSlidingDrawer(Context context, AttributeSet attrs) {
super(context, attrs);
int orientation = attrs
.getAttributeIntValue("android", "orientation", ORIENTATION_VERTICAL);
mTopOffset = attrs.getAttributeIntValue("android", "topOffset", 0);
mVertical = (orientation == SlidingDrawer.ORIENTATION_VERTICAL);
}
public static BaseDSL.ViewClassResult slidingDrawer() {
return BaseDSL.v(SlidingDrawer.class);
}
public static Void slidingDrawer(Anvil.Renderable r) {
return BaseDSL.v(SlidingDrawer.class, r);
}
public static Void onDrawerClose(SlidingDrawer.OnDrawerCloseListener arg) {
return BaseDSL.attr("onDrawerClose", arg);
}
public static Void onDrawerOpen(SlidingDrawer.OnDrawerOpenListener arg) {
return BaseDSL.attr("onDrawerOpen", arg);
}
public static Void onDrawerScroll(SlidingDrawer.OnDrawerScrollListener arg) {
return BaseDSL.attr("onDrawerScroll", arg);
}
public static BaseDSL.ViewClassResult slidingDrawer() {
return BaseDSL.v(SlidingDrawer.class);
}
public static Void slidingDrawer(Anvil.Renderable r) {
return BaseDSL.v(SlidingDrawer.class, r);
}
public static Void onDrawerClose(SlidingDrawer.OnDrawerCloseListener arg) {
return BaseDSL.attr("onDrawerClose", arg);
}
public static Void onDrawerOpen(SlidingDrawer.OnDrawerOpenListener arg) {
return BaseDSL.attr("onDrawerOpen", arg);
}
public static Void onDrawerScroll(SlidingDrawer.OnDrawerScrollListener arg) {
return BaseDSL.attr("onDrawerScroll", arg);
}
public BrowseDrawerListener(Activity activity, SlidingDrawer drawer, BrowseFragment browse) {
mActivity = activity;
mDrawer = drawer;
mBrowse = browse;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.main);
// Set the control stream to STREAM_MUSIC to suppress system beeps
// that sound even when the activity handles volume key events.
setVolumeControlStream(AudioManager.STREAM_MUSIC);
Preferences pref = Preferences.get(this);
isHideDVDTab = pref.isHideDVDTabSet();
String authority = pref.getAuthority();
if (authority != null) {
mMediaServer = new MediaServer(this, authority);
setServerSubtitle(pref.isServerSubtitleSet());
}
mFlipper = (ViewFlipper) findViewById(R.id.flipper);
mPager = (LockableViewPager) findViewById(R.id.pager);
mTabHost = (TabHost) findViewById(android.R.id.tabhost);
mVolumePanel = new VolumePanel(this);
BrowseFragment browse = null;
FragmentUtil fu = new FragmentUtil(getSupportFragmentManager());
fu.findOrAddFragment(Tags.FRAGMENT_STATUS, StatusFragment.class);
if(mTabHost == null) {
fu.findOrReplaceOptionalFragment(this, R.id.fragment_navigation, Tags.FRAGMENT_NAVIGATION, NavigationFragment.class);
fu.findOrReplaceFragment(R.id.fragment_playlist, Tags.FRAGMENT_PLAYLIST, PlaylistFragment.class);
browse = fu.findOrReplaceFragment(R.id.fragment_browse, Tags.FRAGMENT_BROWSE, BrowseFragment.class);
fu.findOrReplaceFragment(R.id.fragment_playback, Tags.FRAGMENT_PLAYBACK, PlaybackFragment.class);
fu.findOrReplaceFragment(R.id.fragment_info, Tags.FRAGMENT_INFO, InfoFragment.class);
fu.findOrReplaceOptionalFragment(this, R.id.fragment_art, Tags.FRAGMENT_ART, ArtFragment.class);
fu.findOrReplaceFragment(R.id.fragment_buttons, Tags.FRAGMENT_BUTTONS, ButtonsFragment.class);
VolumeFragment mVolume = fu.findOrReplaceFragment(R.id.fragment_volume, Tags.FRAGMENT_VOLUME, VolumeFragment.class);
setVolumeFragmentVisible(mVolume != null);
} else {
setupTabHost();
mPager.setOffscreenPageLimit(4);
mPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager(), pref.isHideDVDTabSet()));
mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
mTabHost.setCurrentTab(position);
}
});
if(savedInstanceState != null) {
fu.removeFragmentsByTag(
Tags.FRAGMENT_PLAYBACK, Tags.FRAGMENT_INFO, Tags.FRAGMENT_BUTTONS,
Tags.FRAGMENT_VOLUME, Tags.FRAGMENT_BOTTOMBAR, Tags.FRAGMENT_BROWSE,
Tags.FRAGMENT_NAVIGATION, Tags.FRAGMENT_PLAYLIST
);
}
}
mDrawer = (SlidingDrawer) findViewById(R.id.drawer);
if (mDrawer != null) {
BrowseDrawerListener listener = new BrowseDrawerListener(this, mDrawer, browse);
mDrawer.setOnDrawerOpenListener(listener);
mDrawer.setOnDrawerCloseListener(listener);
}
if (savedInstanceState == null) {
onNewIntent(getIntent());
} else {
notifyMediaServerListeners();
}
}
public SlidingDrawerAssert(SlidingDrawer actual) {
super(actual, SlidingDrawerAssert.class);
}