-2
我有兩個類A和B A是主要活動類,B是視圖類。現在我正在通過setcontentview調用View。當視圖是活動的,我正在繪製它。我希望活動課是活躍的,所以我該怎麼做?如何從視圖移動到活動並回到android
public class A extends Activity {
B b;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.button);
b = new B(this);
Button but = (Button) findViewById(R.id.showView);
but.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(drawView);
drawView.requestFocus();
}
});
}
}
public class b extends View implements OnTouchListener {
public DrawView(Context context) {
super(context);
setFocusable(true);
mContext = context;
setFocusableInTouchMode(true);
this.setBackgroundColor(Color.WHITE);
this.setOnTouchListener(this);
paint.setColor(Color.GRAY);
paint.setAntiAlias(true);
}
public void onDraw(Canvas canvas) {
mCanvas = canvas;
draw something
}
}
什麼問題? – DeeV
當視圖處於活動狀態時,我想返回活動視圖 – Arjit