• 検索結果がありません。

Get Started Developing for Android with @gabu's code

N/A
N/A
Protected

Academic year: 2018

シェア "Get Started Developing for Android with @gabu's code"

Copied!
31
0
0

読み込み中.... (全文を見る)

全文

(1)

Get Started Developing for Android with @gabu's code

PralineWebDesign

梅田 悦子 (Etsuko Umeda)

(2)

The leader of Android Nagoya Developer Club

Android 名古屋

塚田 翔也 (Shoya Tsukada) 紹介

/ 未踏 /Android/GAE/HTML5/ / 東海 GTUG

30 Android アプ Google App Inventor う!

http://www.amazon.co.jp/exec/obidos/ASIN/4883377660/gabu-22/

Android SDK

http://j.mp/gabubook1

@gabu

(3)

We can study his Android Code here.

Reading the source code you can find out how to make.

Android 再入門 - 目次

1. 作成 http://qiita.com/items/8bc1a11f1382409f1d2a

2. 作成 http://qiita.com/items/cff2fbfbd2822f842862

3. View http://qiita.com/items/f9b4389ae0c03f525f04

4. う&前編' http://qiita.com/items/614f89a9f659565806a6

5. う&後編' http://qiita.com/items/6ed716bb9af7cc3c26a3

Android 再入門 - Twitter イアン - 目次

1. Twitter API 使うアプ http://qiita.com/items/4a63e6b56dd50da1f528

2. Twitter4J 準備 http://qiita.com/items/f6f39900fd5e449045f9

3. OAuth 認証 http://qiita.com/items/673288c3a5b39f89aa92

4. イン 表示 http://qiita.com/items/53857fcfa871b921af45

5. ぶやく http://qiita.com/items/ac505aac0ccf2b3d0b42

@gabu's SampleCoad on GitHub

https://github.com/gabu/android-twitter-sample

(4)

Get the Android SDK

The Android SDK provides you the API libraries and developer tools

necessary to build, test, and debug apps for Android.

http://developer.android.com/sdk/index.html

It's mine.

(5)
(6)
(7)
(8)
(9)
(10)
(11)
(12)
(13)
(14)
(15)
(16)

The necessary preparation for Andoroid has been completed.

(17)
(18)
(19)

Coffee Break

AIR Aprication

ActionScript + Flash

Windows8 Aprication

Windows PHone

C# + VisualStudio

Android Aprication

Java + Eclipse

similar

ンや ニ ー ー バー い ー ーイン ー イ & UI' コン ーネン &構成要素' 開

環境 含 い コー イン 画面 分離 う い

The workbench contains a number of standard components which demonstrate the role of a view.

it's part of the design of Eclipse to separate the UI components - the View layer from the Model layer

(20)

Android 再入門 - View http://qiita.com/items/f9b4389ae0c03f525f04

Photoshop いう 背景

MainActivity.Java activity_main.xml 呼び

(21)

Android 再入門 - View http://qiita.com/items/f9b4389ae0c03f525f04

package com.example.helloworld;

import android.app.Activity; import android.os.Bundle; import

android.view.Menu; import android.view.View; import

android.widget.EditText; import android.widget.TextView; import android.widget.Toast;

public class MainActivity extends Activity {

@Override

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

setContentView(R.layout.activity_main); }

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu);

return true;

public void click(View view) {}

EditText input = (EditText) findViewById(R.id.editText1); String text = input.getText().toString();

TextView main = (TextView) findViewById(R.id.textView1); main.setText(text);

Toast.makeText(this,text, Toast.LENGTH_SHORT).show(); }

}

MainActivity.Java

(22)

activity_main.xml

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" >

<TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"

android:layout_centerHorizontal="true" android:layout_centerVertical="true"

android:text="@string/hello_world" />

<Button android:onClick="click" android:id="@+id/button1"

android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/editText1"

android:layout_marginTop="24dp"

android:text="@string/Button"

/>

<EditText android:id="@+id/editText1" android:layout_width="wrap_content"

android:layout_height="wrap_content" android:layout_alignParentTop="true" android:ems="10"

android:inputType="text"

android:labelFor="@+id/editText1" /> </RelativeLayout>

Android 再入門 - View http://qiita.com/items/f9b4389ae0c03f525f04

(23)

Android 再入門 - View http://qiita.com/items/f9b4389ae0c03f525f04

string.xml

設定 い ー地獄 せ

<?xml version="1.0" encoding="utf-8"?>

<string

name="app_name">HelloWorld</string>

<string

name="action_settings">Settings</string>

<string

name="hello_world">Hello world!</string>

<string

name="Button">Button</string>

</resources>

ここ 設

定 こ activity_mail.xml

android:text="@string/Button"

R. java 自動生成さ

public static final class string {

public static final int Button=0x7f050003;

public static final int action_settings=0x7f050001;

public static final int app_name=0x7f050000;

public static final int hello_world=0x7f050002; }

string.xml UI 変数名 設定

(24)

Android 再入門 - http://qiita.com/items/6ed716bb9af7cc3c26a3

string.xml UI 変数名 設定

+ - 場合

activity_main.xml

<TextView android:id="@+id/textView1"

android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:text="@string/zero"

android:textSize="90sp" />

<Button android:id="@+id/button1" android:layout_width="150dp" android:layout_height="150dp"

android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:onClick="plus"

android:text="@string/plus" android:textSize="60sp" />

<Button android:id="@+id/button3" android:layout_width="80dp" android:layout_height="60dp"

android:layo ut_alignBaseline="@+id/button2" android:layout_alignBottom="@+id/button2" android:layout_alignParentRight="true" android:layout_marginRight="30dp" android:onClick="minus"

android:text="@string/minus" />

<Button android:id="@+id/button2" android:layout_width="80dp" android:layout_height="60dp"

android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_marginBottom="30dp" android:layout_marginLeft="30dp" android:onClick="clear"

android:text="@string/Clear" />

<?xml version="1.0"

encoding="utf-8"?><resources>

<string name="app_name">Counter</string>

<string name="action_settings">Settings</string>

<string name="hello_world">Hello world!</string>

<string name="zero">0</string>

<string name="plus">+</string>

<string name="minus">-</string> <string

name="Clear">Clear</string></resources>

(25)

Summary

open Android SDK manager

make string.xml

make activity_main.xml

Run configurations

make MainActivity.java

open

AndroidVirtualDevices

Set up AndroidVirtual Devices Manager

(26)

I wrote All source code in java. Only use MainActivity.java

package com.example.activitytest;

import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast;

import android.widget.LinearLayout; import android.view.ViewGroup; import android.widget.Button;

public class MainActivity extends Activity { private final int WRAP_CONTENT =

ViewGroup.LayoutParams.WRAP_CONTENT;

@Override

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); setContentView(linearLayout);

final TextView tv = new TextView(this); tv.setText("

Hello World!

");

linearLayout.addView(tv,

new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); final EditText edit = new EditText(this);

edit.setWidth(200);

linearLayout.addView(edit,

new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); Button button1 = new Button(this);

button1.setText("Button"); linearLayout.addView(button1,

new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); button1.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

CharSequence str = edit.getText().toString( tv.setText(str);

Toast.makeText(getApplication(), str, Toast.LENGTH_LONG).show(); });}} main_activity.xml (stay Default)

RelativeLayout

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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" ></RelativeLayout>

(27)

At First , Add Activity" NextActivity " into Android Manifest .xml

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.activitytest"

android:versionCode="1" android:versionName="1.0" > <uses-sdk

android:minSdkVersion="17" android:targetSdkVersion="17" />

<application

android:allowBackup="true"

android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >

<activity

android:name="com.example.activitytest.MainActivity" 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:name="com.example.activitytest.NextActivity" android:label="@string/app_name" >

</activity>

</application>

</manifest>

Starting Another Activity with @gabu's code

Respond to the Send Button; Build an Intent; Start the Second Activity

(28)

Secondary,make NextActivity.java ( "No use NextActivity.xml"Version )

package com.example.activitytest; import android.app.Activity; import android.content.Intent; import android.os.Bundle;

import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast;

public class NextActivity extends Activity {

@Override

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); setContentView(ll);

Intent intent = getIntent(); if(intent != null){

String str = intent.getStringExtra("inputtext");

Toast.makeText(this, str, Toast.LENGTH_LONG).show(); TextView tv = new TextView( this );

tv.setText( str );

ll.addView( tv ); }

}}

Starting Another Activity with @gabu's code

Respond to the Send Button; Build an Intent; Start the Second Activity

(29)

Tertiary,make activity_main.xml and strings.xml

(This is the same code that We made before)

activity_main.xml

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" >

<TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" />

<EditText android:id="@+id/editText1"

android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView1" android:layout_below="@+id/textView1" android:layout_marginTop="24dp" android:ems="10"

android:inputType="text"

android:labelFor="@+id/editText1" ><requestFocus /></EditText>

<Button android:id="@+id/button1"

android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/editText1" android:layout_below="@+id/editText1" android:layout_marginTop="24dp" android:labelFor="@+id/button1" android:onClick="click" android:text="@string/Button" />

</RelativeLayout>

Starting Another Activity with @gabu's code

strings.xml

<?xml version="1.0" encoding="utf-8"?>

<resources>

<string name="app_name">ActivityTest</string>

<string name="action_settings">Settings</string>

<string name="hello_world">Hello world!</string>

<string name="Button">Button</string>

</resources>

(30)

Finally,make MainActivity.java

package com.example.activitytest; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast;

public class MainActivity extends Activity {

@Override

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

setContentView(R.layout.activity_main); }

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu);

return true; }

public void click(View view) {

EditText input = (EditText) findViewById(R.id.editText1); String text = input.getText().toString();

TextView main = (TextView) findViewById(R.id.textView1); main.setText(text);

Toast.makeText(this,text, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this,NextActivity.class); intent.putExtra("inputtext", text);

intent.setAction(Intent.ACTION_VIEW); startActivity(intent); }}

Starting Another Activity with @gabu's code

(31)

Starting Another Activity

参照

関連したドキュメント

携帯端末が iPhone および iPad などの場合は App Store から、 Android 端末の場合は Google Play TM から「 GENNECT Cross 」を検索します。 GENNECT

EU の指令 Restriction of the use of certain Hazardous Substances in Electrical and Electronic Equipment の略称。詳しくは以下の URL

新製品「G-SCAN Z」、 「G-SCAN Z Tab」を追加して新たにスタート 新製品「G-SCAN Z」、 「G-SCAN Z

サーバー API 複雑化 iOS&amp;Android 間で複雑な API

If the above mentioned goods, exempted from customs duty and internal tax, are offered for use other than the personal use of yourself or your family, within 2 years after the

[r]

After having refuted the Bhāṭṭa view of intrinsic validity, Jayanta (in section 4.3) defends his view of extrinsic validity from the criticism by the Bhāṭṭas and establishes

That: When that is used, the speaker (conceptualizer 1) invites the hearer (conceptualizer 2) to jointly attend to the object of conceptualization and