'전송!' 버튼은 선택하면..
방법은 다음과 같습니다.
1. MainView에 버튼 만들기
2. ResultView 만들기
<?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"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/nameTextMsg"
/>
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/editTextMsg"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/cityTextMsg"
/>
<Spinner
android:id="@+id/citySpinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/cityChoiceMsg"
/>
<Button
android:text="@string/sendButtonName"
android:id="@+id/sendButton"
android:layout_height="wrap_content"
android:layout_width="match_parent"
/>
</LinearLayout>
package CMJ.AppDev001;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
public class AppDevTest extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Spinner
Spinner spinner1 = (Spinner) findViewById(R.id.citySpinner);
ArrayAdapter adapter1 = ArrayAdapter.createFromResource(this, R.array.city, android.R.layout.simple_spinner_item);
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(adapter1);
//Button
Button btnCall = (Button)findViewById(R.id.sendButton);
btnCall.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(AppDevTest.this, ResultView.class);
startActivity(intent);
}
});
}
<?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">
<TextView
android:text="@string/resultMsg"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:text="@string/nameResult"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:text="@string/cityResult"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:text="@string/previousButtonName"
android:id="@+id/previousButton"
android:layout_height="wrap_content"
android:layout_width="match_parent"
/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, AppDevTest!</string>
<string name="app_name">MainView</string>
<string name="nameTextMsg">이름입력</string>
<string name="editTextMsg">이름을 입력하세요.</string>
<string name="cityTextMsg">도시선택</string>
<string name="cityChoiceMsg">도시선택하기~</string>
<string name="sendButtonName">전송!</string>
<string name="resultMsg">결과!!</string>
<string name="nameResult">이름: </string>
<string name="cityResult">도시: </string>
<string name="previousButtonName">이전으로</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="CMJ.AppDev001"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<!-- MainViewActivity -->
<activity android:name=".AppDevTest"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- ResultViewActivity -->
<activity
android:name=".ResultView"
android:label="ResultView"
/>
</application>
</manifest>
※ 관련소스는 다음에서 확인가능합니다.
이상입니다. 감사합니다.
[안드로이드] 배경화면, 버튼이미지 변경 (LinearLayout) (4) | 2011.06.12 |
---|---|
[안드로이드] Intent의 활용 (데이터 전송) (5) | 2011.06.08 |
Introduction to Replication (0) | 2011.05.27 |
Maintaining High Availability(고가용성) (0) | 2011.05.27 |
Automation (0) | 2011.05.26 |
댓글 영역