本文整理汇总了Java中android.widget.SlidingDrawer.OnDrawerOpenListener类的典型用法代码示例。如果您正苦于以下问题:Java OnDrawerOpenListener类的具体用法?Java OnDrawerOpenListener怎么用?Java OnDrawerOpenListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnDrawerOpenListener类属于android.widget.SlidingDrawer包,在下文中一共展示了OnDrawerOpenListener类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initViews
import android.widget.SlidingDrawer.OnDrawerOpenListener; //导入依赖的package包/类
@Override
public void initViews() {
mImgUp = (RelativeLayout) findViewById(R.id.shakeImgUp);
mImgDn = (RelativeLayout) findViewById(R.id.shakeImgDown);
mTitle = (RelativeLayout) findViewById(R.id.shake_title_bar);
mDrawer = (SlidingDrawer) findViewById(R.id.slidingDrawer1);
mDrawerBtn = (Button) findViewById(R.id.handle);
mDrawer.setOnDrawerOpenListener(new OnDrawerOpenListener()
{
public void onDrawerOpened()
{
mDrawerBtn.setBackgroundDrawable(getResources().getDrawable(
R.drawable.shake_report_dragger_down));
TranslateAnimation titleup = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, -1.0f);
titleup.setDuration(200);
titleup.setFillAfter(true);
mTitle.startAnimation(titleup);
}
});
/* 设定SlidingDrawer被关闭的事件处理 */
mDrawer.setOnDrawerCloseListener(new OnDrawerCloseListener()
{
public void onDrawerClosed()
{
mDrawerBtn.setBackgroundDrawable(getResources().getDrawable(
R.drawable.shake_report_dragger_up));
TranslateAnimation titledn = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, -1.0f,
Animation.RELATIVE_TO_SELF, 0f);
titledn.setDuration(200);
titledn.setFillAfter(false);
mTitle.startAnimation(titledn);
}
});
mShakeListener = new ShakeListener(this);
mShakeListener.setOnShakeListener(new OnShakeListener() {
public void onShake() {
// Toast.makeText(getApplicationContext(),
// "抱歉,暂时没有找到在同一时刻摇一摇的人。\n再试一次吧!", Toast.LENGTH_SHORT).show();
startAnim(); // 开始 摇一摇手掌动画
mShakeListener.stop();
startVibrato(); // 开始 震动
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// Toast.makeText(getApplicationContext(),
// "抱歉,暂时没有找到\n在同一时刻摇一摇的人。\n再试一次吧!",
// 500).setGravity(Gravity.CENTER,0,0).show();
Toast mtoast;
mtoast = Toast.makeText(getApplicationContext(),
"抱歉,暂时没有找到\n在同一时刻摇一摇的人。\n再试一次吧!", 10);
// mtoast.setGravity(Gravity.CENTER, 0, 0);
mtoast.show();
mVibrator.cancel();
mShakeListener.start();
}
}, 2000);
}
});
findViewById(R.id.back).setOnClickListener(this);
findViewById(R.id.done).setOnClickListener(this);
}