설.현.아빠
setVisibility 속성을 사용하여 Intro화면부터 사용안내화면 컨트롤하기. 본문
AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="lee.hyeontae.LayoutEx" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8"
/> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".LayoutEx" 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:label="@string/app_name" android:name=".MainView" android:clearTaskOnLaunch="true" android:finishOnTaskLaunch="false" android:launchMode="singleTask" android:configChanges="orientation" android:screenOrientation="unspecified"></activity> </application> </manifest> |
splash_screen.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"> <LinearLayout android:id="@+id/splash1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/intro"
/> <LinearLayout android:id="@+id/splash2" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/info" android:visibility="gone"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:background="#8e8e8e" android:textColor="#ffffff" android:textStyle="bold" android:textSize="17dip" android:padding="2dip" android:text="@string/usage_info_header"
/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#555555" android:textSize="13dip" android:paddingTop="45dip" android:paddingLeft="25dip" android:paddingRight="25dip" android:text="@string/usage_info_body"
/> <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="25dip" android:paddingRight="25dip"> <CheckBox android:id="@+id/usage_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content"
/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="13dip" android:textColor="#555555" android:text="@string/usage_info_cb"
/> </LinearLayout> <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal"> <Button android:id="@+id/usage_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/button" android:layout_margin="1dip" android:paddingTop="5dip" android:paddingBottom="5dip" android:paddingLeft="30dip" android:paddingRight="30dip" android:textSize="14dip" android:text=" 동의함 " /> </LinearLayout> </LinearLayout> </LinearLayout> |
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"> <FrameLayout android:id="@+id/frame" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/poi_details" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:visibility="invisible"> <LinearLayout android:layout_width="fill_parent" android:layout_height="100px" android:orientation="horizontal" android:paddingLeft="12px" android:background="@drawable/tap_title_480" android:visibility="visible"> <ImageView android:id="@+id/poi_icon" android:layout_width="82px" android:layout_height="92px" android:layout_gravity="bottom"/> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:paddingLeft="12px"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <TextView android:id="@+id/poi_title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_gravity="center_vertical" android:gravity="center_vertical" android:paddingRight="100px" android:textSize="25px" android:text="스타벅스 동수원점" android:singleLine="true" android:ellipsize="end"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <TextView android:id="@+id/poi_distance" android:layout_gravity="center_vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#00ccff" android:gravity="center_vertical" android:textSize="30px" android:text="135m"/> </LinearLayout> </LinearLayout> </LinearLayout> <LinearLayout android:id="@+id/more_information" android:layout_width="fill_parent" android:layout_height="140px" android:orientation="vertical" android:gravity="center_vertical" android:padding="12px" android:background="@drawable/tap_title_infomation_480" android:visibility="invisible"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="25px" android:text="주소: "/> <TextView android:id="@+id/poi_address" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="25px" android:text="경기도 수원시 팔달구 효원로 23번지"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:minHeight="40px" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:textSize="25px" android:text="전화번호 : "/> <TextView android:id="@+id/poi_telephone" android:layout_width="wrap_content" android:layout_height="fill_parent" android:textSize="25px" android:text="031-345-6789"/> <Button android:id="@+id/call_btn" android:layout_width="44px" android:layout_height="45px" android:layout_marginLeft="10px" android:background="@drawable/btn_call_selector" /> </LinearLayout> </LinearLayout> </LinearLayout> <Button android:id="@+id/more_information_button_show_portrait" android:layout_width="380px" android:layout_height="100px" android:background="@drawable/tap_icon_down_480_selector" android:visibility="invisible" /> <Button android:id="@+id/more_information_button_hide_portrait" android:layout_width="380px" android:layout_height="100px" android:background="@drawable/tap_icon_up_480_selector" android:visibility="invisible" /> <Button android:id="@+id/more_information_button_show_landscape" android:layout_width="700px" android:layout_height="100px" android:background="@drawable/tap_icon_down_800_selector" android:visibility="invisible" /> <Button android:id="@+id/more_information_button_hide_landscape" android:layout_width="700px" android:layout_height="100px" android:background="@drawable/tap_icon_up_800_selector" android:visibility="invisible" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingTop="277px"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"> <Button android:id="@+id/left_arrow" android:layout_width="70px" android:layout_height="126px" android:background="@drawable/btn_back" android:visibility="invisible"/> </LinearLayout>
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center|right"> <Button android:id="@+id/right_arrow" android:layout_width="70px" android:layout_height="126px" android:background="@drawable/btn_prv" android:visibility="gone"/> </LinearLayout> </LinearLayout> </FrameLayout> </LinearLayout> |
button.xml <?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/button_pressed"
/> <item android:drawable="@drawable/button_normal"
/> </selector> |
LayoutEx.java package lee.hyeontae.LayoutEx; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.widget.Button; import android.widget.CheckBox; import android.widget.LinearLayout; public class LayoutEx extends Activity implements OnClickListener{ LinearLayout splash1, splash2; Button ok_btn; CheckBox checkbox; Context context; /**
filename of the shared_preferences file used**/ public final static String AR_SETTINGS_FILENAME = "ARSettings"; SharedPreferences arSettings; /**
Constants used for Startup Remember **/ public final static int NO = 0; public final static int YES = 1; public final static String SETUP_STARTUP_REMEMBER = "startup_remember"; private final int END_SPLASH = 1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.splash_screen); context = this; InitViews(); InitSettings(); splashThread().start(); } private void InitViews(){ splash1 = (LinearLayout)findViewById(R.id.splash1); splash2 = (LinearLayout)findViewById(R.id.splash2); checkbox = (CheckBox) findViewById(R.id.usage_checkbox); ok_btn = (Button)findViewById(R.id.usage_button); ok_btn.setOnClickListener(this); } private void InitSettings() { arSettings = this.getSharedPreferences(AR_SETTINGS_FILENAME, MODE_WORLD_WRITEABLE); SharedPreferences.Editor
arSettingsEditor = arSettings.edit(); arSettingsEditor.putInt(SETUP_STARTUP_REMEMBER, NO); arSettingsEditor.commit(); } private Thread
splashThread() { return new Thread(new Runnable()
{ public void run() { try { for(int i=0;i<7;i++) Thread.sleep(500); handler.sendEmptyMessage(END_SPLASH); } catch (Exception e) { } } }); } public Handler handler = new Handler() { @Override public void handleMessage(Message msg) { splash1.setVisibility(View.GONE); if(arSettings.getInt(SETUP_STARTUP_REMEMBER, NO)==NO){ splash2.setVisibility(View.VISIBLE); } else { Intent i = new Intent(context, MainView.class); startActivity(i); finish(); } } }; @Override public void onClick(View v) { if(v == ok_btn){ if(checkbox.isChecked()){ SharedPreferences.Editor
arSettingsEditor = arSettings.edit(); arSettingsEditor.putInt(SETUP_STARTUP_REMEMBER, YES); arSettingsEditor.commit(); } } Intent intent = new Intent(context, MainView.class); startActivity(intent); finish(); } } |
MainView.xml package lee.hyeontae.LayoutEx; import android.app.Activity; import android.os.Bundle; import android.view.Window; public class MainView extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); } } |
String.xml <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, LayoutEx!</string> <string name="app_name">LayoutEx</string> <string name="usage_info_header">사용 안내 </string> <string name="usage_info_body">본 제품은 경기도 지역 내 생활 위치 정보를 제공하는 어플리케이션 입니다.\n\n 모든 위치정보는 경기도에서 제공하는 데이터이며, 위치정보 수신을 위해 무선인터넷을 사용하므로, 3G망을 사용할 시에는 데이터 요금이 부과될 수 있습니다.\n\n GPS
사용시 사용자의 위치정보를 사용하게 되므로 위치정보 사용에 대한 동의 하에 서비스를 제공합니다.\n\n 모든 정보는 현재위치 주변의 공공시설물 및 상업시설을 찾기 위한 참고용으로만 사용해 주시기 바라며, 사용 중 발생하는 모든 책임은 사용자에게 있습니다. \n\n 위의 내용을 이해하였고, 사용 안내에 대하여 동의하며 프로그램을 시작하겠습니다. </string> <string name="usage_info_cb">이 창을 다시 열지 않기.</string> </resources> |
'안드로이드 > Layout' 카테고리의 다른 글
[Android] <include layout /> 인클루드 레이아웃 (0) | 2011.07.01 |
---|