[Android]fragment_main.xmlがなくて困ったらの巻

スポンサーリンク

android-logoAndroidアプリの作成をしよう!と思って、こんな問題にぶち当たった

fragment_main.xmlがない

というのも、参考にしているAndroidディベロッパーのページ「Building a Simple User Interface」にて必要とされている”fragment_main.xml”がないんです。

スポンサーリンク

Create a Linear Layout


Open the fragment_main.xml file from the res/layout/ directory.

引用元:http://developer.android.com/training/basics/firstapp/building-ui.html

そこで少し調べましたら、英語のページですが答えを見つけることができました。

対策

以下のとおりの英文を発見しました。

Hi, I think you can effectively work around this issue by selecting “Blank activity with Fragment” in the tutorial instead of just “Blank Activity” – doing so will create the file fragment_main.xml in res/layout/ which is needed to continue following the steps.

If anyone has time and access to edit the pages in the official tutorial, that’d be helpful as well. All they need to reflect is the choice of “Blank Activity with Fragment” – very minor edit/fix.

引用元:https://code.google.com/p/android/issues/detail?id=67421#c16

上記の太字の部分に記載があるとおり
プロジェクト作成時のActivityを選択するときに、「Blank Activity」を選択せずに「Blank activity with Fragment」を選択すること、それだけで”fragment_main.xml”が作成されます。

実際に私もやってみました。Eclipseを日本語化していないので日本語でどのような選択になるのかはわかりませんが、以下のような作業で無事に”fragment_main.xml”が作成されました!

参考までに以下に実施時の画像を掲載しておきます。

1. 新規Projectの作成を開始します。

01

2. 「Android Application Project」を選択して「Next」を押します。

02

3. Application Nameに任意のものを入力し、「Next」を押します。私の場合「MyFirstApp」としました。

03

4. 特に何も変更せずに「Next」を押します。

Creat custom luncher iconとか今は必要ないのでチェックをはずしてもいいと思います。

04

5. アイコンの設定を変更する必要はありませんのでそのまま「Next」を押します。

05

6. ここで、「Blank Activity with Fragment」を選択して「Next」を押します。

06

7. ここでの設定変更は必要ないのでそのまま「Next」を押します。

07

8. はい。これで完成しました。

08

以上です。

コメント

タイトルとURLをコピーしました