Android 抽屉式Activity
2012-07-17 14:06:29 来源:WEB开发网核心提示: @Override public void onItemClick( AdapterView<?> arg0, View arg1, int arg2, long arg3) {// if (String[0]) {//// }//if (arg2 == 1) { Intent intent = new
@Override
public void onItemClick(
AdapterView<?> arg0,
View arg1,
int arg2, long arg3) {
// if (String[0]) {
//
// }
//
if (arg2 == 1) {
Intent intent = new Intent(
SettingActivity.this,
Gongzibai.class);
startActivity(intent);
finish();
public void onItemClick(
AdapterView<?> arg0,
View arg1,
int arg2, long arg3) {
// if (String[0]) {
//
// }
//
if (arg2 == 1) {
Intent intent = new Intent(
SettingActivity.this,
Gongzibai.class);
startActivity(intent);
finish();
}
if (arg2==3) {
Intent intent1 = new Intent(
SettingActivity.this,
Gongzibai1.class);
startActivity(intent1);
finish();
}
close();
if (arg2==3) {
Intent intent1 = new Intent(
SettingActivity.this,
Gongzibai1.class);
startActivity(intent1);
finish();
}
close();
}
});
open();
}
});
open();
}
public void initAnim() {
// 采用了绝对布局,绝对布局是view的左上角从(0,0)开始
@SuppressWarnings("deprecation")
final android.widget.AbsoluteLayout.LayoutParams lp = new android.widget.AbsoluteLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT,
0, 0);
findViewById(
R.id.slideout_placeholder)
.setLayoutParams(lp);
@SuppressWarnings("deprecation")
final android.widget.AbsoluteLayout.LayoutParams lp = new android.widget.AbsoluteLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT,
0, 0);
findViewById(
R.id.slideout_placeholder)
.setLayoutParams(lp);
// 屏幕的宽度
int displayWidth = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay()
.getWidth();
// 右边的位移量,60dp转换成px
int sWidth = (int) TypedValue
.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
60,
getResources()
.getDisplayMetrics());
// 将快照向右移动的偏移量
final int shift = displayWidth
- sWidth;
int displayWidth = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay()
.getWidth();
// 右边的位移量,60dp转换成px
int sWidth = (int) TypedValue
.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
60,
getResources()
.getDisplayMetrics());
// 将快照向右移动的偏移量
final int shift = displayWidth
- sWidth;
// 向右移动的位移动画向右移动shift距离,y方向不变
mStartAnimation = new TranslateAnimation(
TranslateAnimation.ABSOLUTE,
0,
TranslateAnimation.ABSOLUTE,
shift,
TranslateAnimation.ABSOLUTE,
0,
TranslateAnimation.ABSOLUTE,
0);
mStartAnimation = new TranslateAnimation(
TranslateAnimation.ABSOLUTE,
0,
TranslateAnimation.ABSOLUTE,
shift,
TranslateAnimation.ABSOLUTE,
0,
TranslateAnimation.ABSOLUTE,
0);
更多精彩
赞助商链接