不贊成使用類型庫。
不贊成使用來自類型庫的onKeyDown(int,KeyEvent)方法。
示例代碼自定義圖庫在Android中已棄用?
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.Gallery;
public class mygallery extends Gallery {
public mygallery(Context ctx, AttributeSet attrSet) {
super(ctx, attrSet);
}
private boolean isScrollingLeft(MotionEvent e1, MotionEvent e2){
return e2.getX() > e1.getX();
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY){
int kEvent;
if(e2.getX() > e1.getX()){
kEvent = KeyEvent.KEYCODE_DPAD_LEFT;
}
else{
kEvent = KeyEvent.KEYCODE_DPAD_RIGHT;
}
onKeyDown(kEvent, null);
return true;
}
}
如何解決這個過時
棄用意味着Android團隊不會更多地保留Gallary。你想解決什麼問題? – Blackbelt
什麼是替代解決方案。 –
水平滾動視圖或列表視圖水平 –