One of the things important is not to forget permission to the Manifest. Already become habit to forget.
중요한 것 중의 하나는 Manifest에 permission을 주는 것이다. 자꾸 까먹는다.
Manifest
</activity> <activity android:name=".Part01" android:label="Part01"> </activity>
|
MainActivity.java
public class MainActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); }
public void mOnClick_part1(View v){ Intent intent_part01 = new Intent(this, Part01.class); startActivity(intent_part01); }
}
|
Part01.java
public class Part01 extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.part01); } }
|
activity_main.xlm
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center">
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Part01" android:id="@+id/button_part1" android:onClick="mOnClick_part1" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:background="#ff1725" /> </RelativeLayout> |
part01.xlm
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="500dp">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Part01 호출되었습니다." android:id="@+id/textView" android:layout_gravity="center_horizontal" />
</RelativeLayout> |