HelloFragment/res/layout/activity_main_tab.xml
<LinearLayout 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" >
<fragment
android:id="@+id/fragment1tab"
android:name="com.example.hellofragment.LeftFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2" />
<fragment
android:id="@+id/fragment2tab"
android:name="com.example.hellofragment.RightFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
タブレット用の2ペイン表示のレイアウトXMLファイル
HelloFragment/res/layout/activity_main_sp.xml
<LinearLayout 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" >
<fragment
android:id="@+id/fragment1sp"
android:name="com.example.hellofragment.LeftFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
スマートフォン用のレイアウトXMLファイル
HelloFragment/res/layout/right_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
WebViewを使ったレイアウトXMLファイル
タブレット用の右ペインとスマートフォン用で兼用している
HelloFragment/AndroidManifest.xml
// 抜粋 <uses-permission android:name="android.permission.INTERNET"/>
WebViewでインターネットアクセスするため、上記のパーミッションが必要
参考HP
■[memo]Androidがphoneかtabletかをチェックするには
http://d.hatena.ne.jp/Superdry/20110914/1315969856
■Android Fragment を使う
http://y-anz-m.blogspot.jp/2011/05/androidfragment_19.html
■Android Developers(Fragment)
http://developer.android.com/reference/android/app/Fragment.html