안드로이드 개발 질문/답변
(글 수 45,052)
package com.TestExample2;
package com.TestExample2;
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener;
package com.TestExample2;
public class TestExample extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ViewGroup layout = (ViewGroup) findViewById(R.id.main_layout);
layout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(TestExample.this, TestExample3.class);
startActivity(intent);
}
});
}
}package com.TestExample2;
import android.app.Activity; import android.os.Bundle;
public class TestExample3 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:id="@+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#222"
>
<TextView
android:id="@+id/title_text"
android:text="@string/hello"
android:textSize="50dip"
android:textColor="#000"
android:background="#888"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:layout_width="250dip"
android:layout_height="wrap_content"
></TextView>
</RelativeLayout>
</LinearLayout>
test.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="test" /> </LinearLayout>
안드로이드를 처음 공부하고 있는 학생입니다. 다름이 아니라
메인 화면에 TestExample랑 main.xml을 이용해서 화면에 보여주고
유저가 화면을 클릭하면 TestExample3랑 test.xml을 이용해 화면을 보고 주고 싶습니다
근데 메인 화면에서 클릭만 하면 오류가 나와서 어떤 오류인줄도 자세히 안나와서
염치 없지만 여기에 글을 올립니다. 선배님들 읽어 보고 답변 부탁드립니다
혹시 몰라서 소스 같이 올립니다



