버튼 클릭시 엑티비티 바뀌는 소스입니다. 버튼을 클릭하면
자꾸 Unfortunately,_______________has stopped라고 뜨네요... 오류좀 찾아주세요..
정말 찾아주시면 감사하겠습니다. 안드로이드 초보라..힘드네요..
FirstActivity.java입니다 아래는 코드입니다.
-----------------------------------------------------------------------------------
package com.example.testtest;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.view.View.OnClickListener;
import android.widget.Button;
public class FirstActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
Button button=(Button)findViewById(R.id.first_btn);
button.setOnClickListener(new OnClickListener()
{
public void onClick(View v){
Intent intent=new Intent(FirstActivity.this, SecondActivity.class);
startActivity(intent);
}
});
}
}
-----------------------------------------------------------------------------------
SecondActivity.java입니다 아래는 코드입니다.
-----------------------------------------------------------------------------------
package com.example.testtest;
import android.app.Activity;
import android.os.Bundle;
public class SecondActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
// TODO Auto-generated method stub
}
}
-----------------------------------------------------------------------------------
activity_first.xml입니다 아래는 코드입니다.
-----------------------------------------------------------------------------------
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation = "vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:id="@+id/first_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="let's START"
android:textSize="15sp"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src= "@drawable/main_deco"
android:adjustViewBounds="true"
/>
< /LinearLayout>
-----------------------------------------------------------------------------------
activity_second.xml입니다 아래는 코드입니다.
-----------------------------------------------------------------------------------
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<textView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+string/second"
android:textSize="15sp"
/>
</LinearLayout>
-----------------------------------------------------------------------------------
