当前位置: 编程技术>移动开发
本页文章导读:
▪为啥commons_fileupload.jar包中没有setProgressListener()方法呢 为什么commons_fileupload.jar包中没有setProgressListener()方法呢.
郁闷. 为什么commons_fileupload.jar包中没有setProgressListener()方法呢.我快疯了. 麻烦高人指导. 小弟万分感谢!
......
▪ java 时间的前头 几天的时间 java 时间的前面 几天的时间
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class DateUtils {
// public static void main(String[] args) {
// getTodayTim.........
▪ 自定义解锁滑动旋钮 自定义解锁滑动按钮
实现滑动解锁按钮,附带按钮滑动音效。
public class SlidingButton extends Button {
float offset;
public SlidingButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, .........
[1]为啥commons_fileupload.jar包中没有setProgressListener()方法呢
来源: 互联网 发布时间: 2014-02-18
为什么commons_fileupload.jar包中没有setProgressListener()方法呢.
郁闷. 为什么commons_fileupload.jar包中没有setProgressListener()方法呢.我快疯了. 麻烦高人指导. 小弟万分感谢!
郁闷. 为什么commons_fileupload.jar包中没有setProgressListener()方法呢.我快疯了. 麻烦高人指导. 小弟万分感谢!
[2] java 时间的前头 几天的时间
来源: 互联网 发布时间: 2014-02-18
java 时间的前面 几天的时间
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class DateUtils {
// public static void main(String[] args) {
// getTodayTime() ;
// }
public static void main(String[] args) {
getTodayTime() ;
getBeforeDaysTime(1) ;
getBeforeDaysTime(2) ;
getBeforeDaysTime(3) ;
getBeforeDaysTime(4) ;
getBeforeDaysTime(5) ;
getBeforeDaysTime(6) ;
getBeforeDaysTime(7) ;
getBeforeDaysTime(8) ;
getBeforeDaysTime(9) ;
getBeforeDaysTime(10) ;
getBeforeDaysTime(11) ;
getBeforeDaysTime(12) ;
getBeforeDaysTime(13) ;
getBeforeDaysTime(14) ;
getBeforeDaysTime(15) ;
}
//---------------------------------以上是产生一个随机数的,写错了
//-----下面是日期的代码
/**
* 获取当前的日期
*/
public static String getTodayTime() {
String strTodayTime = "" ; //19880214这样形式
Date now = new Date() ;
SimpleDateFormat f= new SimpleDateFormat("yyyy-MM-dd");
strTodayTime = f.format(now) ;
System.out.println(strTodayTime);
return strTodayTime ;
}
/**
* 得到当前日期的前的第beforData天的日期
* @param beforData
* @return
*/
public static String getBeforeDaysTime(int beforData) {
GregorianCalendar calendar = new GregorianCalendar();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - beforData);
Date date = calendar.getTime();
System.out.println(df.format(date));
return df.format(date);
}
}
2012-06-10 2012-06-09 2012-06-08 2012-06-07 2012-06-06 2012-06-05 2012-06-04 2012-06-03 2012-06-02 2012-06-01 2012-05-31 2012-05-30 2012-05-29 2012-05-28 2012-05-27 2012-05-26
[3] 自定义解锁滑动旋钮
来源: 互联网 发布时间: 2014-02-18
自定义解锁滑动按钮
实现滑动解锁按钮,附带按钮滑动音效。
public class SlidingButton extends Button {
float offset;
public SlidingButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public SlidingButton(Context context) {
super(context);
}
private boolean isMe = false;
private int limit = 302;
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public boolean isMe() {
return isMe;
}
public void setMe(boolean isMe) {
this.isMe = isMe;
}
public SlidingButton(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
offset = event.getX();
isMe = true;
} else if (event.getAction() == MotionEvent.ACTION_UP) {
isMe = false;
}
return false;
}
public boolean handleActivityEvent(MotionEvent activityEvent) {
boolean result = false;
if (isMe()) {
if (activityEvent.getAction() == MotionEvent.ACTION_UP) {
int newX = (int) activityEvent.getX();
if (newX < getLimit() && newX > 100) {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) getLayoutParams();
TranslateAnimation trans = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0, Animation.ABSOLUTE,
-lp.leftMargin, Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0);
trans.setStartOffset(0);
trans.setDuration(500);
trans.setFillBefore(true);
trans.setAnimationListener(new SlidingAnimationListener(
this));
startAnimation(trans);
} else if (newX > getLimit()) {
//SoundPlayer.getInstance().play(SoundPlayer.SLIDE);
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) getLayoutParams();
lp.leftMargin = 0;
setLayoutParams(lp);
isMe = false;
//用户完成了选择动作
result = true;
}
} else {
// 还在拖动
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) getLayoutParams();
lp.leftMargin = (int) (activityEvent.getX() - offset-5);
System.out.println(lp.leftMargin);
if (lp.leftMargin > 0 && lp.leftMargin < (367-149)) {
setLayoutParams(lp);
}
}
}
return result;
}
private static class SlidingAnimationListener implements AnimationListener {
private SlidingButton but;
public SlidingAnimationListener(SlidingButton button) {
this.but = button;
}
@Override
public void onAnimationEnd(Animation animation) {
rePosition();
but.setMe(false);
}
private void rePosition() {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) but
.getLayoutParams();
lp.leftMargin = 0;
but.setLayoutParams(lp);
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
}
}
public class SoundPlayer {
public static int BTN;
public static int LOOP;
private SoundPool soundPool;
private int loopStreamId;
private static SoundPlayer instance;
public static SoundPlayer getInstance() {
synchronized (SoundPlayer.class) {
if (instance == null) {
instance = new SoundPlayer();
}
}
return instance;
}
// 单例
private SoundPlayer() {
soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
}
public void loadSound(Context context) {
BTN = soundPool.load(context, R.raw.button, 1);
LOOP = soundPool.load(context, R.raw.loop, 1);
}
public void play(int soundId) {
if (soundId == LOOP) {
// 循环播放
soundPool.stop(loopStreamId);
loopStreamId = soundPool.play(soundId, 1f, 1f, 1, -1, 1f);
} else {
// 只播放一次
soundPool.play(soundId, 1f, 1f, 1, 0, 1f);
}
}
public void stop() {
soundPool.stop(loopStreamId);
}
}
最新技术文章: