마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

어플 실행시킬때 뜨는 activity를 바꾸고 싶습니다.

0 추천

안녕하십니까

동아리 홈피 제작과 어플을 만들고 어플에 GCM을 올리고 싶어서 공부 하고있는 평범한 대학생 입니다.

 

GCM을 기본으로 두고 일단 어플 제작을 해버려서

메인 화면이 regid와 개인정보 조금 적어서 등록버튼을 누르는 메인 화면이 있습니다. 이 화면을 activity_register.xml로 두겠습니다.

이화면이 어플을 실행시켯을때 뜨는 기본 화면이구요

등록 버튼을 눌렀을때 현재 상태를 텍뷰로 찍어주는 activity_main.xml이 있구요

이제 웹뷰 즉 홈페이지를 보여주기위해 웹뷰소스를 추가하고 에러 다잡았구요.

그런데 어플을 실행시켰을때 뜨는 메인화면이 아직 그대로 activity_register 입니다.

 

여기서 질문

1. 어플 실행시 처음 뜨는 화면을 main 즉 웹뷰로 두고 싶습니다.

2. 메뉴 버튼을 누르면 나타나는 메뉴를 만들고 그 메뉴에 설정 탭을 만들어서 activity_register.xml을 관리 하고 싶습니다

 

이렇게 설정하려면 어느부분을 건드려야 하나요??

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#ffffff" >    
     
     <TextView android:id="@+id/lblMessage" 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:textSize="16dip"
         android:layout_margin="10dip"
         android:textColor="#000000"/>

</LinearLayout>

activity_main.xml 레이아웃
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >    
     
     <TextView android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:text="이름 :"
         android:layout_marginLeft="10dip"
         android:layout_marginRight="10dip"
         android:layout_marginTop="20dip"/>
     
     <EditText android:id="@+id/txtName" 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_margin="10dip"
         android:layout_marginBottom="20dip"/>
     
     <TextView android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:text="이메일 : "
         android:layout_marginLeft="10dip"
         android:layout_marginRight="10dip"/>
     
     <EditText android:id="@+id/txtEmail" 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_margin="10dip"
         android:layout_marginBottom="20dip"/>

     <Button
         android:id="@+id/btnRegister"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_margin="10dip"
         android:text="Register" />

</LinearLayout>

activity_register_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" >
        <WebView        
         android:id="@+id/webview"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"/>
</LinearLayout>

main.xml 레이아웃

소스가 길어서 죄송합니다 ㅠㅠ 일단 레이아웃 부분만 올렷구요

MainActivity.java 부분에 메인 액티비티 밑 웹뷰 부분이 올려저 있습니다.

mainactivity.java 부분에서 설정해야 하는거면 방법좀 알려 주시면 감사하겠습니다

조정하 (450 포인트) 님이 2013년 2월 21일 질문

1개의 답변

+1 추천
시작하는 Activity 는 기술해 주신 java와 xml 에 의해서 결정되는게 아니라, AndroidManifest.xml 에 Intent filter 에 의해서 결정됩니다.

관련 문서는 다음과 같습니다. http://developer.android.com/guide/topics/manifest/manifest-intro.html

Intent filter 관련은 http://developer.android.com/guide/components/intents-filters.html 여기의 ACTION_MAIN 항목을 보고 코딩하세요.

 
ps 안드로이드 플랫폼 특성상, 근본적으로는 앱의 시작점을 조건에 따라서 다르게 Activity 를 실행할수는 없습니다. (현재 안드로이드가 지원하는 xml 은 선언적인 정의만 지원합니다.)  이건 프로그램의 구조를 변경해야하는 거구요. Fragment 를 쓰거나, Activity 를 분기하는 방식으로 구현해보세요.
상인 (6,670 포인트) 님이 2013년 2월 21일 답변
상인님이 2013년 2월 21일 수정
...