如何将活动意图传递给扩展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