안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요 안드로이드에 관심이 많은 학생입니다.
질문좀 할께요,,ㅎㅎ
이렇게된 상황에서 제가 XML파일로 레이아웃을 하나 만들었거든요 이걸 화면에 띄워주고싶거든요...
음..m_bbview 자체가 제가 만든 XML레이아웃이 되게 하려면 어떻게 수정해야되나요???
도와주세요..
질문좀 할께요,,ㅎㅎ
public class Text extends Activity {
Ball m_bbview; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); m_bbview = new Ball(this); setContentView( m_bbview ); } public class Ball extends LinearLayout { public BaseBallView(Context context) { super(context); // TODO Auto-generated constructor stub } @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); } } }
이렇게된 상황에서 제가 XML파일로 레이아웃을 하나 만들었거든요 이걸 화면에 띄워주고싶거든요...
음..m_bbview 자체가 제가 만든 XML레이아웃이 되게 하려면 어떻게 수정해야되나요???
도와주세요..
2010.10.14 15:48:07
답변감사합니다.. 음..좀전에 그렇게 햇었거든요,,,
-------------Text------------------------------
m_resource=getResources();
parser = m_resource.getXml(R.layout.playgame);
attributes = Xml.asAttributeSet(parser);
m_bbview = new Bal(this,attributes);
setContentView(m_bbview);
-------------------------------------------------
public Ball(Context context, AttributeSet attrs) {
super(context,attrs);
// TODO Auto-generated constructor stub
}
이렇게 햇는데 검은 바탕만나와서요...제가 멀 빼먹었나요??ㅠㅠ
-------------Text------------------------------
m_resource=getResources();
parser = m_resource.getXml(R.layout.playgame);
attributes = Xml.asAttributeSet(parser);
m_bbview = new Bal(this,attributes);
setContentView(m_bbview);
-------------------------------------------------
public Ball(Context context, AttributeSet attrs) {
super(context,attrs);
// TODO Auto-generated constructor stub
}
이렇게 햇는데 검은 바탕만나와서요...제가 멀 빼먹었나요??ㅠㅠ
XML에서 쓰시려면 반드시 뷰 생성자에 Context, AttributeSet 두개의 인수를 받는 생성자가 오버라이드 되어야 합니다.