1. RatingBar(레이팅바)


<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="org.android.soldesk.ratingbar_01.RatingBar_01Activity">


<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ratingBar01"
style="?android:attr/ratingBarStyleIndicator"
android:numStars="6"
android:rating="2"
android:stepSize="0.5"
/>

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

<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ratingBar03"
style="?android:attr/ratingBarStyleSmall"
android:numStars="6"
android:rating="4"
android:stepSize="0.5"
/>

</LinearLayout>

<xml>


package org.android.soldesk.ratingbar_01;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.RatingBar;
import android.widget.Toast;

public class RatingBar_01Activity extends AppCompatActivity {

RatingBar rating01;
RatingBar rating02;
RatingBar rating03;



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rating_bar_01);

rating01 = (RatingBar) findViewById(R.id.ratingBar01);
rating02 = (RatingBar) findViewById(R.id.ratingBar02);
rating03 = (RatingBar) findViewById(R.id.ratingBar03);

rating02.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {

Toast.makeText(getApplicationContext(),
"설정값"+rating ,Toast.LENGTH_SHORT).show();

rating01.setRating(rating);
rating03.setRating(rating);
}
});


}
}

<java>




2. 명시적 Intent


<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="org.android.soldesk.indent_011.Indent_011Activity">

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnStart"
android:text="새로운 액티비티 실행"

/>

</LinearLayout>

<xml>


package org.android.soldesk.indent_011;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import org.android.soldesk.indent_011.R;

public class Indent_011Activity extends AppCompatActivity {

Button btnStart;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_indent_011);

btnStart = (Button) findViewById(R.id.btnStart);

btnStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

// 명시적 인텐트 생성

Intent intent = new Intent(getApplicationContext(),NextActivity.class);

// 액티비티 실행

startActivity(intent);
}
});
}
}

<java>


package org.android.soldesk.indent_011;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

public class NextActivity extends AppCompatActivity {

Button btnBack;
Button btnNext;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


setContentView(R.layout.next);

btnBack = (Button) findViewById(R.id.btn2Back);
btnNext = (Button) findViewById(R.id.btn2Next);

btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent aa = new Intent(getApplicationContext(),Next2Activity1.class);

startActivity(aa);
}
});


btnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

// 이전 액티비티로 돌아가기
finish();
}
});
}
}

<NextActivity.java>


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

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView01"
android:text="새로운 액티비티 입니다."
android:textAppearance="?android:attr/textAppearanceMedium"
/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/newImage01"
android:src="@drawable/aa"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn2Back"
android:text="뒤뒤로가기"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn2Next"
android:text="앞으로가기"
/>
</LinearLayout>
</LinearLayout>

<next.xml>


package org.android.soldesk.indent_011;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

/**
* Created by soldesk on 2017-03-24.
*/

public class Next2Activity1 extends AppCompatActivity {

Button btnBackk;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.nextt);

btnBackk = (Button) findViewById(R.id.btn2Backk);

btnBackk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

// 이전 액티비티로 돌아가기
finish();
}
});

}
}

<Next2Activity1.java>


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

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView01"
android:text="새로운 액티비티 입니다."
android:textAppearance="?android:attr/textAppearanceMedium"
/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/newImage01"
android:src="@drawable/f"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn2Backk"
android:text="뒤뒤로가기"
/>



</LinearLayout>

<naxtt.xml>


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.android.soldesk.indent_011">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Indent_011Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".NextActivity"
android:label="NextActivity Test"
/>
<activity
android:name=".Next2Activity1"
android:label="Next2Activity1 Test"
/>
</application>

</manifest>

<AndroidManifest.xml>




3. 묵시적 Intent


<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="org.android.soldesk.intent_03.Intent_03Activity">

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnStart"
android:text="새로운 엑티비티 실행"
/>
</LinearLayout>

<xml>


package org.android.soldesk.intent_03;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Intent_03Activity extends AppCompatActivity {

Button btnStart;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_intent_03);

btnStart = (Button) findViewById(R.id.btnStart);

btnStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 묵시적 인텐트 사용
Intent intent = new Intent("com.intent.action.TestIntent");

startActivity(intent);
}
});
}
}

<java>


package org.android.soldesk.intent_03;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class NextActivity extends AppCompatActivity {

Button btnNext;
Button btnBack;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_next);

btnBack = (Button) findViewById(R.id.btn2Back);
btnNext = (Button) findViewById(R.id.btn2Next);

btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent aa = new Intent("aa.vv.cc.dd");

startActivity(aa);
}
});

btnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

//이전 액티비티로 돌아가기
finish();
}
});

}
}

<NextActivity.java>


<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="org.android.soldesk.intent_03.NextActivity">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/e"

/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn2Back"
android:text="뒤로가기 연습"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn2Next"
android:text="앞으로가기"
/>

</LinearLayout>

<activity_next.xml>


package org.android.soldesk.intent_03;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

/**
* Created by soldesk on 2017-03-24.
*/

public class Next2Activity1 extends AppCompatActivity {

Button btnBackk;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.nextt);

btnBackk = (Button) findViewById(R.id.btn2Backk);

btnBackk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

// 이전 액티비티로 돌아가기
finish();
}
});
}
}

<Next2Activity1.java>


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

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn2Backk"
android:text="뒤로가기"
/>

</LinearLayout>

<nextt.xml>


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.android.soldesk.intent_03">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Intent_03Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<!--묵시적 액티비티 등록-->

<activity
android:name=".NextActivity"
android:label="NextActivity Test ~~~~~">

<intent-filter>
<!-- 사용자 지정 액션 -->
<action android:name="com.intent.action.TestIntent"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".Next2Activity1"
android:label="Next2Activity1 Test ~~~~~">

<intent-filter>
<!-- 사용자 지정 액션 -->
<action android:name="aa.vv.cc.dd"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>

<AndroidManifest.xml>




4. ProgressBar(프로그레스바)


<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="org.android.soldesk.progressbar_1.ProgressBar_1Activity">

<ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ProgressBar01"
style="@android:style/Widget.ProgressBar.Horizontal"
/>
</LinearLayout>

<xml>


package org.android.soldesk.progressbar_1;

import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ProgressBar;

public class ProgressBar_1Activity extends AppCompatActivity {

private static final int PROGRESS = 0x1;

private ProgressBar mProgress;
private int mProgressStatus = 0;
private int count = 0;

private Handler mHandler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_progress_bar_1);

mProgress = (ProgressBar) findViewById(R.id.ProgressBar01);
// 백그라운드 스레드
new Thread(new Runnable() {
@Override
public void run() {
while (true){
if (mProgressStatus < 100)
mProgressStatus += 1;
else
mProgressStatus = 0;

// 프로그레스 바를 업데이트한다.

mHandler.post(new Runnable() {
@Override
public void run() {
mProgress.setProgress(mProgressStatus);
}
});
try {
Thread.sleep(8);
} catch (InterruptedException e){
e.printStackTrace();
}
if (count > 1109){
break;
}
count += 1;
}
}
}).start();

}
}

<java>




5. Intent_05


<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="org.android.soldesk.indent_05.Indent_05Activity">

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnPhone"
android:text="전화해용~~~"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnBrowse"
android:text="브라우져~~~"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnSms"
android:text="SMS!!!!"
/>
</LinearLayout>

<xml>


package org.android.soldesk.indent_05;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Indent_05Activity extends AppCompatActivity {

Button btnPhone;
Button btnBrowser;
Button btnSms;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_indent_05);

//Phone

btnPhone = (Button) findViewById(R.id.btnPhone);
btnPhone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:010-2345-4567"));

startActivity(intent);
}
});

//Browser

btnBrowser = (Button) findViewById(R.id.btnBrowse);
btnBrowser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.co.kr"));

startActivity(intent);

}
});

//SMS

btnSms = (Button) findViewById(R.id.btnSms);
btnSms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:010-345-5677"));
startActivity(intent);
}
});

}
}

<java>




6. Intent_Result


<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="org.android.soldesk.indent_result.Indent_ResultActivity">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editName"
android:ems="10"
android:hint="이름을 입력하세요"
>

<requestFocus />

</EditText>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editAge"
android:ems="10"
android:hint="나이을 입력하세요"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editAddress"
android:ems="10"
android:hint="주소을 입력하세요"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editAa"
android:ems="10"
android:hint="월급을 입력하세요"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnSend"
android:text="전송~~~~"
/>

</LinearLayout>

<xml>


package org.android.soldesk.indent_result;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class Indent_ResultActivity extends AppCompatActivity {

EditText editName;
EditText editAge;
EditText editAddress;
EditText editAa;
Button btnSend;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_indent__result);

editName = (EditText) findViewById(R.id.editName);
editAge = (EditText) findViewById(R.id.editAge);
editAddress = (EditText) findViewById(R.id.editAddress);
editAa = (EditText) findViewById(R.id.editAa);

btnSend = (Button) findViewById(R.id.btnSend);

btnSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

// 입력 데이타 얻기

String name = editName.getText().toString();
String age = editAge.getText().toString();
String address = editAddress.getText().toString();
String aa = editAa.getText().toString();

//인텐트 생성 및 데이타 저장

Intent intent = new Intent(getApplicationContext(), NextResultActivity.class);

intent.putExtra("name",name);
intent.putExtra("age",Integer.parseInt(age)); // 정수 값으로 전달
intent.putExtra("address",address);
intent.putExtra("aa",Integer.parseInt(aa));

startActivity(intent);
}
});
}
}

<java>


package org.android.soldesk.indent_result;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
* Created by soldesk on 2017-03-24.
*/

public class NextResultActivity extends AppCompatActivity{

TextView txtResult;
Button btnBack;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.nextresult);

txtResult = (TextView) findViewById(R.id.txtResult);

// 인텐트 얻기

Intent intent = getIntent();

String name = intent.getStringExtra("name");
int age = intent.getIntExtra("age",25); // 25 default 값
String address = intent.getStringExtra("address");
int aa = intent.getIntExtra("aa",100);

String msg = "이름은 : " +name+ ", 나이는 : " +age+ ", 주소 : " +address+", 월급 : "+(aa*1.5);

txtResult.setText(msg);


btnBack = (Button) findViewById(R.id.btnBack);

btnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});

}
}

<NextResultActivity.java>


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.android.soldesk.indent_result">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Indent_ResultActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<activity
android:name=".NextResultActivity"
android:label="NextResultActivity Test"
/>
</application>

</manifest>

<AndroidManifest.xml>


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

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtResult"
android:text="전송된 데이타 출력"
android:textAppearance="?android:attr/textAppearanceLarge"
/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnBack"
android:text="뒤뒤로~~~"
/>

</LinearLayout>

<nextresult.xml>


+ Recent posts