public class UITestActivity extends Activity {
static Context context;
GameView gameView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gameView = new GameView(this);
setContentView(gameView);
}
}
Activity 에 gameView가 위처럼 올라갑니다.
그리고, gameView위에 TextView를 띄울려고 하는데 화면에 textView가 안보이네요 ㅠ
아래는 gameView 클래스입니다.
public class GameView extends View implements Runnable{
TextView textview;
public GameView(Activity activity) {
super(context);
textView = new TextView (activity);
textView.setText("TESTTTTTTTTTT");
textView.setBackgroundColor(0xffffff);
textView.setGravity(Gravity.CENTER);
textView.setTextColor(Color.RED);
textView.setTextSize(36.0f);
textView.setVisibility(VISIBLE);
// 이부분이 gameView위에 textView를 뛰울려고 하는 부분입니다.
activity.addContentView(textView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
}




Activity를 받아서 GameView에서 Context등록하고 다시 Activity에 setcontenview로 View를 설정한다?
좀 이상한거같네요 ㅎ;
UITestActivity 의 UI xml파일형태로 추가하셔서 UITestActivity 에서 해당 View를 올려보세요
<pkg경로.GameView
android:id="@+id/touch"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent">
</pkg경로.GameView >