안드로이드 개발 - 2017년 8월 17일 목요일
안드로이드 어플을 개발해보려고 한다.
<구성항목>
버튼 2개 + 배너광고
<설치 파일>
<코멘트>
생각보다 대소문자 구분을 정확히 해야된다는 걸 느꼈다. 아이템 구성하는데 조금씩 익숙해져 가는 것 같은데..
아직 갈길이 멀다 ㅠ
<코드구성>
res/layout/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.heison.mytestnote.MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onButton1Clicked"
android:text="안녕, 안드로이드!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.235"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.173" />
<Button
android:layout_width="153dp"
android:layout_height="46dp"
android:layout_marginTop="179dp"
android:onClick="onButton2Clicked"
android:text="SDI 상황보기"
app:layout_constraintHorizontal_bias="0.835"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
app:adSize="BANNER"
app:adUnitId="@string/banner_ad_unit_id"
tools:layout_editor_absoluteX="32dp"
tools:layout_editor_absoluteY="358dp" />
</android.support.constraint.ConstraintLayout>
manifests/AndoridManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.heison.mytestnote">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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=".MainActivity">
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent"/>
</application>
</manifest>
MainActivity.java
package com.example.heison.mytestnote;
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.Toast;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initAdmob();
}
public void onButton1Clicked(View v){
Toast.makeText(getApplicationContext(),"시작 버튼이 눌렸어요", Toast.LENGTH_LONG).show();
}
public void onButton2Clicked(View v){
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://m.stock.naver.com/item/main.nhn#/stocks/006400/total"));
startActivity(myIntent);
}
private void initAdmob(){
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
mAdView.loadAd(adRequestBuilder.build());
}
}
'정보나눔 > IT (기술)' 카테고리의 다른 글
노키아 9 PureView, 도대체 카메라가 몇개야? (0) | 2019.02.26 |
---|---|
나의최애캐 어플로 제 모습을 꾸며보았어요~ (3) | 2018.11.01 |
쏠폰 제조사, TCL의 자회사 알카텔 원터치는 어떤 기업일까요? (4) | 2016.01.19 |
skt sol(쏠) 스펙, 사양, 가격을 간단히 살펴보았습니다~ (4) | 2016.01.18 |
갤럭시 A5 2016, 갤럭시 A7 2016. 스펙과 가격 살펴봅시다~ (2) | 2016.01.14 |
댓글