main.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="wrap_content"
        android:text="@string/hello" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="나는 main" />


    <RatingBar
        android:id="@+id/ratingBar1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>
sub.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="나는 sub " />

</LinearLayout>
IntentActivity.java 23번 줄 에러 로 manifest설정 




androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.gusfree.intent"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".IntentActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="SubActivity"></activity>
    </application>

</manifest>
IntentActivity.java
package com.gusfree.intent;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

public class IntentActivity extends Activity implements OnClickListener{

	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        findViewById(R.id.button1).setOnClickListener(this);
    }

	@Override
	public void onClick(View v) {
		//버튼 누르면 Sub로 Activity간 이동하기
		Intent intent =new Intent();
		intent.setClass(this, SubActivity.class);
		startActivity(intent);//이동//error
	}
}
SubActivity.java
package com.gusfree.intent;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

public class SubActivity extends Activity implements OnClickListener{
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sub);
		
		findViewById(R.id.button1).setOnClickListener(this);
	}

	@Override
	public void onClick(View arg0) {
		finish();//액티비티 종료
	}
}






'Android > 2012.04월 강좌' 카테고리의 다른 글

5일차 Intent2  (2) 2012.05.02
5일차 LogCat을 사용한 error 찾기  (0) 2012.05.02
5일차 Grid  (0) 2012.05.02
5일차 계산기  (0) 2012.05.02
5일차 계산기(내가 한것)  (0) 2012.05.02

+ Recent posts