Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Androidアプリのしくみ
Search
@nekoruri
November 02, 2013
Technology
8.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Androidアプリのしくみ
Androidアプリのしくみ
(オブジェクト指向の基礎の基礎)
日本Androidの会 秋葉原支部
コスプレ理系女子普及部
第18回定例会 LT資料
@nekoruri
November 02, 2013
More Decks by @nekoruri
See All by @nekoruri
技術系同人誌を書こう #ssmjp
nekoruri
0
140
Twitter OAuth vulnerability
nekoruri
0
120
Other Decks in Technology
See All in Technology
その Lambda、8分で 管理者権限まで奪われます
k1nakayama
7
3.5k
AIを活用するために決めた "やらないこと" - 価値に注目する / Not betting on AI
soudai
PRO
3
570
今話題のAI「Jev」って何? 宇宙最速で学ぶ会
minorun365
PRO
30
18k
新機種発売前に見直そう!端末移行で再ログインが要るアプリ・要らないアプリは何が違うのか 〜シームレスに再開できる設計と実装〜
zozotech
PRO
0
220
AIに任せた品質は、誰が見立てるのか - AI時代のテストマネジメント
nakanao
3
2.7k
AIによるクリエイティブ生成を行う上での試行錯誤
plaidtech
PRO
0
170
Oracle Cloud Network Path Analyzerを試してみた/I Tried Out Oracle Cloud Network Path Analyzer
masakiokuda
1
110
Making AI Agents Safe and Fast- Jev, Obsidian, and the Meta-Harness
x5gtrn
PRO
0
110
Cloudflare Workers 向けアプリを C# で構築する ~WASM Native AOT への道~
nenonaninu
1
920
負債のメタファと2026年 / Debt Metaphor in Agentic Engineering Age 202609 Edition
twada
PRO
10
4.8k
Slack上でインフラをトラブルシュートする! Agentic Platform Engineeringの第一歩
teru0x1
5
1.8k
越境するなら専門用語を使うな高校校歌 / If you wanna cross border, you shouldn't use jargon
vtryo
0
150
Featured
See All Featured
Unsuck your backbone
ammeep
672
58k
The Curse of the Amulet
leimatthew05
3
15k
A Tale of Four Properties
chriscoyier
163
24k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Google's AI Overviews - The New Search
badams
0
1.6k
WENDY [Excerpt]
tessaabrams
14
39k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
430
Agile that works and the tools we love
rasmusluckow
331
22k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
It's Worth the Effort
3n
188
29k
Designing for Performance
lara
611
70k
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
Transcript
日本Androidの会 秋葉原支部 コスプレ理系女子普及部 第18回定例会
今まで書いてきたプログラムを、 「外側」 から説明してみます。
なんとなくでいいので イメージ を掴めると理解がすすむ 今まで書いてきたプログラムを、 「外側」 から説明してみます。
なんとなくでいいので イメージ を掴めると理解がすすむ はず! 今まで書いてきたプログラムを、 「外側」 から説明してみます。
public class MainActivity extends Activity { @Override protected void onCreate(Bundle
savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } アプリを起動したら、 onCreateを呼ぶよ!
実はonCreate以外にも呼んでるよ! 削除したonCreateOptionsMenuとかね! たくさんの「基本的な動き方」が、ひな形( Activity )に書かれています。 いつも最初に削除するonCreateOptionsMenuもです。 それを呼んでいるのが「 super.onCreate 」です。 public
class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }
Activity Androidアプリの基本的な動き方が 書かれています MainActivity 自分のアプリ独自の部分を書きます MainActivityに書かれていないことは、 Activityに書いてあることをやるよ!
public class MainActivity extends Activity { (onCreateは省略) public void onClick1(View
v){ setContentView(R.layout.self_introduction); } } ボタンがクリックされたら onClick1を呼ぶよ! そしたら、setContentViewするよ!
setContentViewしろって言われたけど、 MainActivityには書いていないから、 Activityに書いてある内容を実行するね! 実は、setContentView の内容は Activity に書かれています。 そういう、呼ぶと何かしてくれる「メソッド」がたくさん定義されています。 public class
MainActivity extends Activity { (onCreateは省略) public void onClick1(View v){ setContentView(R.layout.self_introduction); } }
公式ドキュメントを見てみよう http://developer.android.com/reference/android/app/Activity.html 「Public Methods」がメソッドの一覧
public class MainActivity extends Activity { TextView tv; public void
onClick1(View v) { setContentView(R.layout.self_introduction); tv = (TextView) findViewById(R.id.textView1); tv.setText(“実はスポーツマン”); } ボタンがクリックされたら textView1の文字を 「実はスポーツマン」に変えるよ!
public class MainActivity extends Activity { TextView tv; public void
onClick1(View v) { setContentView(R.layout.self_introduction); tv = (TextView) findViewById(R.id.textView1); tv.setText(“実はスポーツマン”); } textView1を変数 tv に入れて、 tvのsetTextメソッドを呼ぶよ!
レイアウトファイルを読んで、 ボタンと文字の 「インスタンス」を作るよ! レイアウトファイル 「文字列の表示方法」 「ボタンの表示方法」 「ボタンが押されたら onClick1を呼ぶ」 こんにちは! onClick1
ボタンが押されたら、 onClickを呼ぶよ! ボタン 文字列の「インスタンス」に setTextで文字を変えるよう 命令するよ!
public class MainActivity extends Activity { TextView tv; public void
onClick1(View v) { setContentView(R.layout.self_introduction); tv = (TextView) findViewById(R.id.textView1); tv.setText(“実はスポーツマン”); } こんにちは! ボタン findViewByIdを使って、 Androidが作ってくれたインスタンスをさす 矢印を変数にいれます この矢印を通してメソッドを呼んで、 「命令」をインスタンスに送ります レイアウトファイル に従って作られた 画像やボタンの 「インスタンス」
public class MainActivity extends Activity { TextView tv; public void
onClick1(View v) { setContentView(R.layout.self_introduction); tv = (TextView) findViewById(R.id.textView1); tv.setText(“実はスポーツマン”); tv = (TextView) findViewById(R.id.textView2); tv.setText(“わたしの戦闘力は53万です。”); } こんにちは! ボタン 自己紹介
public class MainActivity extends Activity { TextView tv; public void
onClick1(View v) { setContentView(R.layout.self_introduction); tv = (TextView) findViewById(R.id.textView1); tv.setText(“実はスポーツマン”); tv = (TextView) findViewById(R.id.textView2); tv.setText(“わたしの戦闘力は53万です。”); } こんにちは! ボタン 自己紹介 同じ変数に 「別のインスタンスをさす矢印」 をいれなおすこともできます
やっぱり公式ドキュメントを見てみよう! http://developer.android.com/reference/android/widget/TextView.html
Androidのプログラム(MainActivity)は、既にある 「ひな形」(Activity)の上に作っていきます。 レイアウトで置いたボタンや文字は、 プログラム開始時にAndroidが作ってくれます。 それぞれを「インスタンス」と言います。 findViewByIdでそのインスタンスへの「矢印」を変
数に入れます。 変数に入れた矢印を経由して「命令」を送ります。 これが「メソッド」です。