Androidアプリ開発入門 / Android Studio (Preview) 0.6.1

IDEAndroid Studio

疑問点

 状態:-  閲覧数:1,364  投稿日:2014-10-19  更新日:2018-02-25
プロジェクトのパス
・デフォルト「C:/Users/Administrator/AndroidStudioProjects/」から変更すると正常動作しなくなる

選択したエミュレータによっては正常動作しないことがある
・Android4.4.2-19 … エミュレータは起動するも画面は真っ黒のまま
・Google4.4.2-19 … 正常動作


ショートカット


Shiftキー2回
・検索ウインドウポップアップ

Alt + 番号
・左端に縦表示されているパネル切替

Alt + Enter
・ポップアップメニュー表示
・「IMPORT CLASS」を選択すると、必要クラス読込記述を自動追記


Androidアプリ開発入門 (全12回)

エミュレータでアプリケーションを起動する手順は、2通り

 閲覧数:338 投稿日:2014-10-22 更新日:2014-10-22

2種類


A.最初にエミュレータを起動
・最初にエミュレータ起動後、アプリケーションより(既に起動済みの)エミュレータを指定

B.同時にエミュレータを起動
・選択したアプリケーションより、(起動する)エミュレータを指定して起動


Choose Device画面


Choose a running Device
・上に表示されるチェックボックス
・「A.最初にエミュレータを起動」している場合は、この欄に該当エミュレーション名が表示されるので、選択

Launch emulator
・下に表示されるチェックボックス
・「B」のエミュレータ起動していない場合は、このプルダウンより(起動する)エミュレータを指定する

両者の違い
・自分で作成したエミュレータは、「A.最初にエミュレータを起動」でしか選択できない

基本的な処理の流れ

 閲覧数:342 投稿日:2014-10-23 更新日:2014-10-24

1.AndroidManifest.xml


▼C:/Users/Administrator/AndroidStudioProjects/MyApp01/app/src/main/AndroidManifest.xml
・最初に、「android.intent.action.MAIN」を読込
<action android:name="android.intent.action.MAIN" />


・次に、そこで指定されたアクティビティを読込
 android:name="net.e1blue.android0.myapp01.MyActivity"



2.MyActivity.java


▼C:/Users/Administrator/AndroidStudioProjects/MyApp01/app/src/main/java/net/e1blue/android0/myapp01/MyActivity.java
・MyActivity.java読込
・最初にonCreateメソッド読込
・R.layoutで指定された「activity_my」読込
    protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_my);
   }



3.activity_my.xml


▼C:/Users/Administrator/AndroidStudioProjects/MyApp01/app/src/main/res/layout/activity_my.xml
・activity_my.xml読込

指定ボタンクリックしたら、「Clicked」とログ表示

 閲覧数:350 投稿日:2014-10-24 更新日:2014-10-24
▼C:/Users/Administrator/AndroidStudioProjects/MyApp01/app/src/main/java/net/e1blue/android0/myapp01/MyActivity.java
public class MyActivity extends Activity {

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

   public void changeLabel(View view){
       Log.v("TEST", "Clicked");
   }


▼C:/Users/Administrator/AndroidStudioProjects/MyApp01/app/src/main/res/layout/activity_my.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:paddingLeft="@dimen/activity_horizontal_margin"
   android:paddingRight="@dimen/activity_horizontal_margin"
   android:paddingTop="@dimen/activity_vertical_margin"
   android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MyActivity">

   <TextView android:text="@string/hello_world" android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_centerVertical="true"
       android:layout_centerHorizontal="true"
       android:id="@+id/myLabel" />

   <Button
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="Click me!"
       android:id="@+id/myButton"
       android:layout_marginTop="38dp"
       android:layout_below="@+id/myLabel"
       android:layout_centerHorizontal="true"
       android:onClick="changeLabel" />

</RelativeLayout>


・結果
10-23 21:31:01.290      869-869/net.e1blue.android0.myapp01 V/TEST﹕ Clicked
10-23 21:31:03.900      869-869/net.e1blue.android0.myapp01 V/TEST﹕ Clicked
10-23 21:31:04.350      869-869/net.e1blue.android0.myapp01 V/TEST﹕ Clicked
10-23 21:31:04.660      869-869/net.e1blue.android0.myapp01 V/TEST﹕ Clicked
10-23 21:31:04.900      869-869/net.e1blue.android0.myapp01 V/TEST﹕ Clicked
10-23 21:31:05.160      869-869/net.e1blue.android0.myapp01 V/TEST﹕ Clicked
10-23 21:31:05.350      869-869/net.e1blue.android0.myapp01 V/TEST﹕ Clicked
10-23 21:31:37.590      869-869/net.e1blue.android0.myapp01 V/TEST﹕ Clicked
10-23 21:32:16.665      869-869/net.e1blue.android0.myapp01 V/TEST﹕ Clicked


指定ボタンクリックしたら、ラベルテキスト表示変更

 閲覧数:403 投稿日:2014-10-24 更新日:2014-10-24
▼C:/Users/Administrator/AndroidStudioProjects/MyApp01/app/src/main/java/net/e1blue/android0/myapp01/MyActivity.java
public class MyActivity extends Activity {

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

   public void changeLabel(View view){
       //Log.v("TEST", "Clicked");
       TextView tv = (TextView)findViewById(R.id.myLabel);
       tv.setText("Changed!");
   }



Android Studio v0.4.2 for Windows

Android Stusio バージョンアップ方法が不明 / Android Stusio 0.5.1



週間人気ページランキング / 5-12 → 5-18
順位 ページタイトル抜粋 アクセス数
アクセスが、ありませんでした! 0
2024/5/19 1:01 更新