0
UserDetailActivity Class

    public class UserDetailActivity extends FragmentActivity implements OnClickListener

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

        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.user_detail, menu);
            return true;
        }
}

安卓清单

<uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="16" />
    <permission 
        android:name="com.hrishikesh.landlordbuddy.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>
    <uses-permission android:name="com.hrishikesh.landlordbuddy.permission.MAPS_RECEIVE"/>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <!-- The following two permissions are not required to use
         Google Maps Android API v2, but are recommended. -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <uses-feature 
        android:glEsVersion="0x00020000"
        android:required="true"/>
 <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <uses-library android:name="com.google.android.maps" />
       <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyD1AMCmj2MY2RUR6sn4yC4XdOfnG4PJvxg"/>
</application>

原木猫

11-10 14:35:50.307: E/AndroidRuntime(29147): FATAL EXCEPTION: main
11-10 14:35:50.307: E/AndroidRuntime(29147): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hrishikesh.landlordbuddy/com.hrishikesh.landlordbuddy.UserDetailActivity}: android.view.InflateException: Binary XML file line #39: Error inflating class fragment
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2355)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.app.ActivityThread.access$600(ActivityThread.java:151)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.os.Looper.loop(Looper.java:155)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.app.ActivityThread.main(ActivityThread.java:5493)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at java.lang.reflect.Method.invokeNative(Native Method)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at java.lang.reflect.Method.invoke(Method.java:511)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:795)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at dalvik.system.NativeStart.main(Native Method)
11-10 14:35:50.307: E/AndroidRuntime(29147): Caused by: android.view.InflateException: Binary XML file line #39: Error inflating class fragment
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:358)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.app.Activity.setContentView(Activity.java:1912)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at com.hrishikesh.landlordbuddy.UserDetailActivity.onCreate(UserDetailActivity.java:23)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.app.Activity.performCreate(Activity.java:5066)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)
11-10 14:35:50.307: E/AndroidRuntime(29147):    ... 11 more
11-10 14:35:50.307: E/AndroidRuntime(29147): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.MapFragment cannot be cast to android.support.v4.app.Fragment
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.support.v4.app.Fragment.instantiate(Fragment.java:402)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.support.v4.app.Fragment.instantiate(Fragment.java:377)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277)
11-10 14:35:50.307: E/AndroidRuntime(29147):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
11-10 14:35:50.307: E/AndroidRuntime(29147):    ... 25 more

布局 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"
    tools:context=".UserDetailActivity" >

    <TabHost
        android:id="@+id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </TabWidget>

           <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <LinearLayout
                    android:id="@+id/details_tab"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:paddingBottom="@dimen/activity_vertical_margin"
                    android:paddingLeft="@dimen/activity_horizontal_margin"
                    android:paddingRight="@dimen/activity_horizontal_margin"
                    android:paddingTop="@dimen/activity_vertical_margin" >
                    <fragment 
                        android:id="@+id/map"
                        class="com.google.android.gms.maps.SupportMapFragment"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"/>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="vertical"   >

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/name_text" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/address_text" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/phone_text" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/email_text" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/amount_due_text" />
                        <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" >

                            <Button
                                android:id="@+id/notify_button"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_above="@+id/delete_button"
                                android:layout_alignParentLeft="true"
                                android:text="@string/notify_button_text" />

                            <Button
                                android:id="@+id/delete_button"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_alignParentBottom="true"
                                android:layout_alignParentLeft="true"
                                android:text="@string/delete_button_text" />
                    </RelativeLayout>

                    </LinearLayout>


                </LinearLayout>

                <LinearLayout
                    android:orientation="horizontal"
                    android:id="@+id/records_tab"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <TableLayout
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:stretchColumns="0,1,2" >   

                        <TableRow
                            android:layout_width="fill_parent">
                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="Month"
                                />
                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="Paid"
                                />

                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="Due"
                                />  
                        </TableRow>

                        <TableRow
                            android:layout_width="fill_parent">
                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="September"
                                />
                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="$1500.00"
                                />

                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="$1900.00"
                                />  
                        </TableRow>

                        <TableRow
                            android:layout_width="fill_parent">
                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="August"
                                />
                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="$3400.00"
                                />

                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="$0.00"
                                />  
                        </TableRow>

                        <TableRow
                            android:layout_width="fill_parent">
                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="July"
                                />
                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="$3400.00"
                                />

                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="$0.00"
                                />  
                        </TableRow>

                        <TableRow
                            android:layout_width="fill_parent">
                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="TOTAL"
                                />
                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="$8300.00"
                                />

                            <TextView
                                android:padding="3dip"
                                android:gravity="center"
                                android:text="$1900.00"
                                />  
                        </TableRow>


                    </TableLayout>

                </LinearLayout>

            </FrameLayout>
        </LinearLayout>
    </TabHost>

</RelativeLayout>
4

0 回答 0