如何將活動意圖傳遞給擴展surfaceview的類?將活動的意圖傳遞給擴展surfaceview的類?
繼承人的發送出去的意圖代碼:
btnCutOutter.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
//Send intent to cut image from user selection path
//See designCanvas.java for details
String optionSelected = "Yes";
Intent myIntent = new Intent(view.getContext(), designCanvas.class);
myIntent.putExtra("id",optionSelected);
}
});
當我嘗試檢索意圖數據:
public class designCanvas extends SurfaceView implements SurfaceHolder.Callback {
//Create shape using Path
Path mPath = new Path();
private drawThread _thread;
private ArrayList<GraphicObject> _graphics = new ArrayList<GraphicObject>();
public designCanvas(Context context, AttributeSet attributes) {
super(context, attributes);
getHolder().addCallback(this);
setFocusable(true);
_thread = new drawThread(getHolder(), this);
String optionSelected = getIntent().getStringExtra("id");
. . .
我對日食獲悉:
The method getIntent() is undefined
如果有人能給我這樣的指導,我將非常感謝:)
非常感謝。
你的問題沒有太大的意義,使用意圖僅在活動中。爲什麼你需要將一個意圖傳遞給SurfaceView? – triggs 2012-02-07 15:23:28
我需要將意圖傳遞到Surface View,因爲我想控制SurfaceView內代碼的結果。爲了進一步定義我的問題,我將如何將數據從一個類傳遞到另一個類,記住其中一個類沒有活動。 – Odhran 2012-02-07 15:31:23