Android Studioを起動します。
【準備】
1.「Android Studio1.2(141.1980579)のインストール方法」でAndroid Studioをインストールしておきます。
【手順1】
1.Android Studioのインストール場所に移動。
2.『bin』ディレクトリに移動。
3.『studio64.exe』を実行。
1.『実行』ボタンをクリック。
1.起動を待ちます。
1.以下の様に起動すれば成功です。
以上です。
| 項目名 | 項目に設定する値 |
| アプリケーション名(Application Name) | com.example.androidsample53_006 |
| プロジェクト名(Project Name) | AndroidSample53-006-FragmentView |
| パッケージ名(Package Name) | com.example.androidsample53_006 |
| Minimum Required SDK | API 14 |
| Target SDK | API 14 |
| Compile With | API 14 |
| Theme | Theme Holo Light |
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidsample53_006"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="14" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="AndroidSample53-006"
android:theme="@style/AppTheme" >
<activity android:name="com.example.androidsample53_006.MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
2.「Ctrl+Shift+F」を押し、コードをフォーマッティング。<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light" ></style>
</resources>
2.「Ctrl+Shift+F」を押し、コードをフォーマッティング。<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/fragment1"
android:name="com.example.androidsample53_006.Fragment1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<fragment
android:id="@+id/fragment2"
android:name="com.example.androidsample53_006.Fragment2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
2.「Ctrl+Shift+F」を押し、コードをフォーマッティング。<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical" >
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="変更" />
</LinearLayout>
3.「Ctrl+Shift+F」を押し、コードをフォーマッティング。<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:orientation="vertical" >
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:textColor="@android:color/white" />
</LinearLayout>
3.「Ctrl+Shift+F」を押し、コードをフォーマッティング。package com.example.androidsample53_006;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
2.「Ctrl+Shift+F」を押し、コードをフォーマッティング。package com.example.androidsample53_006;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
public class Fragment1 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment1, container, false);
}
@Override
public void onStart() {
super.onStart();
Button button = (Button) getActivity().findViewById(R.id.button);
final TextView text = (TextView) getActivity().findViewById(R.id.text);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
text.setText("World");
}
});
}
}
2.「Ctrl+Shift+F」を押し、コードをフォーマッティング。package com.example.androidsample53_006;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment2 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment2, container, false);
}
}
2.「Ctrl+Shift+F」を押し、コードをフォーマッティング。