2014年1月5日

ImageButton

ImageButton 自訂義類別

class ImageButtonA extends ImageButton implements OnTouchListener,
OnClickListener, OnFocusChangeListener {
MainActivity mainActivity;
public ImageButtonA(Context context) {
super(context);
mainActivity = (MainActivity) context;
setBackgroundResource(R.drawable.ic_launcher);
  //載入圖片
setOnClickListener(this);
setOnFocusChangeListener(this);
setOnTouchListener(this);
}

public boolean onTouch(View v, MotionEvent event) {
return false;
}

public void onClick(View arg0) {
setBackgroundResource(R.drawable.ic_launcher);
}

public void onFocusChange(View arg0, boolean isFocused) {
// TODO Auto-generated method stub
}
}

沒有留言:

張貼留言