2013-06-27 19 views
1

不贊成使用類型庫。
不贊成使用來自類型庫的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; 
    } 
} 

如何解決這個過時

+1

棄用意味着Android團隊不會更多地保留Gallary。你想解決什麼問題? – Blackbelt

+0

什麼是替代解決方案。 –

+0

水平滾動視圖或列表視圖水平 –

回答

0

使用默認的畫廊,並與該適配器的定製view.It將getView()來完成創建其ImageAdapter。