单击片段页面时,App force将关闭

时间:2017-01-19 11:39:43

标签: java android

我设计了Android应用的个人资料页面。但是,当我点击此页面时,它会强制关闭。我怎样才能防止崩溃?

Reference of my profile page

Resource files

RES /布局/ fragment_profile_vp.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.ray.myoufd.Profile_vp">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/header_cover_image"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:scaleType="centerCrop"
            android:src="@drawable/profilebg" />

        <ImageButton
            android:id="@+id/user_profile_photo"
            android:layout_width="120dp"
            android:layout_height="120dp"
            android:layout_below="@+id/header_cover_image"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="-60dp"
            android:elevation="5dp"
            android:scaleType="centerCrop"
            android:src="@drawable/defaultpropic" />

        <RelativeLayout
            android:id="@+id/profile_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/header_cover_image"
            android:background="@color/grey"
            android:elevation="4dp"
            android:paddingBottom="24dp">


            <TextView
                android:id="@+id/user_profile_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="76dp"
                android:text="Name"
                android:textColor="#fff"
                android:textSize="24sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/user_profile_short_bio"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/user_profile_name"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="12dp"
                android:text="profile short bio"
                android:textColor="#fff"
                android:textSize="14sp" />
        </RelativeLayout>


        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/profile_layout"
            android:layout_marginTop="0dp"
            android:orientation="horizontal"
            android:id="@+id/linearLayout1"
            android:background="@color/white">

            <TextView
                android:layout_height="wrap_content"
                android:text="Name:"
                android:layout_width="wrap_content"
                android:textSize="18sp"
                android:layout_margin="5dp"
                android:textColor="@color/green"/>

            <EditText
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:textColor="@color/black"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/profile_layout"
            android:layout_marginTop="43dp"
            android:orientation="horizontal"
            android:id="@+id/linearLayout2"
            android:background="@color/white">

            <TextView
                android:layout_height="wrap_content"
                android:text="Gender:"
                android:layout_width="wrap_content"
                android:textSize="18sp"
                android:layout_margin="5dp"
                android:textColor="@color/green"/>

            <EditText
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:textColor="@color/black"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/profile_layout"
            android:layout_marginTop="86dp"
            android:orientation="horizontal"
            android:id="@+id/linearLayout3"
            android:background="@color/white" >

            <TextView
                android:layout_height="wrap_content"
                android:text="Email:"
                android:layout_width="wrap_content"
                android:textSize="18sp"
                android:layout_margin="5dp"
                android:textColor="@color/green"/>

            <EditText
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:textColor="@color/black"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/profile_layout"
            android:layout_marginTop="129dp"
            android:orientation="horizontal"
            android:id="@+id/linearLayout4"
            android:background="@color/white">

            <TextView
                android:layout_height="wrap_content"
                android:text="Date o birth:"
                android:layout_width="wrap_content"
                android:textSize="18sp"
                android:layout_margin="5dp"
                android:textColor="@color/green"/>

            <EditText
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:textColor="@color/black"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/profile_layout"
            android:layout_marginTop="172dp"
            android:orientation="vertical"
            android:id="@+id/linearLayout5"
            android:background="@color/white">

            <TextView
                android:layout_height="wrap_content"
                android:text="Message to friend"
                android:layout_width="wrap_content"
                android:textSize="18sp"
                android:layout_margin="5dp"
                android:textColor="@color/green"/>

            <EditText
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:textColor="@color/black"/>
        </LinearLayout>

            <Button
                android:text="Logout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/button"
                android:layout_marginStart="115dp"
                android:layout_marginLeft="115dp"
                android:background="@color/green"
                android:layout_marginTop="605dp" />

            <Button
                android:text="Save"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/button2"
                android:layout_marginTop="605dp"
                android:layout_marginLeft="210dp"
                android:layout_marginStart="210dp"
                android:background="@color/green"
            />
    </RelativeLayout>
</ScrollView>
</FrameLayout>

的java / com.example.ray.myoufd / Profile_vp.java

package com.example.ray.myoufd;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class Profile_vp extends Fragment {


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_profile_vp, container, false);
    }

}

的java / com.example.ray.myoufd / MainPage.java

package com.example.ray.myoufd;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.gigamole.navigationtabbar.ntb.NavigationTabBar;

import java.util.ArrayList;
import java.util.List;

public class MainPage extends AppCompatActivity {

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

    private void initUI() {
        final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_horizontal_ntb);

        final String[] colors = getResources().getStringArray(R.array.default_preview);
        final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb_horizontal);
        final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
        models.add(
                new NavigationTabBar.Model.Builder(
                        getResources().getDrawable(R.drawable.home),
                        Color.parseColor(colors[0]))
                        .title("Home")
                        .build()
        );
        models.add(
                new NavigationTabBar.Model.Builder(
                        getResources().getDrawable(R.drawable.search),
                        Color.parseColor(colors[1]))
                        .title("Search")
                        .build()
        );
        models.add(
                new NavigationTabBar.Model.Builder(
                        getResources().getDrawable(R.drawable.friend),
                        Color.parseColor(colors[2])).
                        badgeTitle("123")
                        .title("Friend")
                        .build()
        );
        models.add(
                new NavigationTabBar.Model.Builder(
                        getResources().getDrawable(R.drawable.personal),
                        Color.parseColor(colors[3]))
                        .title("Profile")
                        .build()
        );
        models.add(
                new NavigationTabBar.Model.Builder(
                        getResources().getDrawable(R.drawable.chat),
                        Color.parseColor(colors[4]))
                        .title("Discuss")
                        .build()
        );

        navigationTabBar.setModels(models);


        Search_vp search_Vp = new Search_vp();
        Home_vp home_vp = new Home_vp();
        Friend_vp friend_vp =new Friend_vp();
        Discuss_vp discuss_vp = new Discuss_vp();
        Profile_vp profile_vp = new Profile_vp();
        List<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(home_vp);
        fragmentList.add(search_Vp);
        fragmentList.add(friend_vp);
        fragmentList.add(profile_vp);
        fragmentList.add(discuss_vp);
        FragmentPageAdapter fragmentPageAdapter =new FragmentPageAdapter(getSupportFragmentManager(),fragmentList);
        viewPager.setAdapter(fragmentPageAdapter);
        navigationTabBar.setViewPager(viewPager, 0);


        navigationTabBar.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(final int position, final float positionOffset, final int positionOffsetPixels) {
            }

            @Override
            public void onPageSelected(final int position) {
                navigationTabBar.getModels().get(position).hideBadge();
            }

            @Override
            public void onPageScrollStateChanged(final int state) {

            }
        });


        navigationTabBar.postDelayed(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < navigationTabBar.getModels().size(); i++) {
                    final NavigationTabBar.Model model = navigationTabBar.getModels().get(i);
                    navigationTabBar.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            model.showBadge();
                        }
                    }, i * 100);
                }
            }
        }, 500);
    }

}

堆栈跟踪

01-20 13:58:18.981 13772-13772/? I/SELinux: Function: selinux_android_load_priority [0], There is no sepolicy file.

01-20 13:58:19.006 13772-13772/? I/SELinux: Function: selinux_android_load_priority , spota verifySig and checkHash pass. priority version is VE=SEPF_GT-N7100_4.4.2_0040


01-20 13:58:19.006 13772-13772/? I/SELinux: selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
01-20 13:58:19.006 13772-13772/? D/dalvikvm: Late-enabling CheckJNI
01-20 13:58:19.076 13772-13772/com.example.ray.myoufd W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
01-20 13:58:19.076 13772-13772/com.example.ray.myoufd I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
01-20 13:58:19.076 13772-13772/com.example.ray.myoufd W/dalvikvm: VFY: unable to resolve interface method 19014: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
01-20 13:58:19.076 13772-13772/com.example.ray.myoufd D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
01-20 13:58:19.076 13772-13772/com.example.ray.myoufd I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
01-20 13:58:19.076 13772-13772/com.example.ray.myoufd W/dalvikvm: VFY: unable to resolve interface method 19018: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
01-20 13:58:19.076 13772-13772/com.example.ray.myoufd D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
01-20 13:58:19.146 13772-13772/com.example.ray.myoufd I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
01-20 13:58:19.146 13772-13772/com.example.ray.myoufd W/dalvikvm: VFY: unable to resolve virtual method 424: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
01-20 13:58:19.146 13772-13772/com.example.ray.myoufd D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
01-20 13:58:19.146 13772-13772/com.example.ray.myoufd I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
01-20 13:58:19.146 13772-13772/com.example.ray.myoufd W/dalvikvm: VFY: unable to resolve virtual method 426: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
01-20 13:58:19.156 13772-13772/com.example.ray.myoufd D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
01-20 13:58:19.476 13772-13772/com.example.ray.myoufd D/libEGL: loaded /system/lib/egl/libEGL_mali.so
01-20 13:58:19.476 13772-13772/com.example.ray.myoufd D/libEGL: loaded /system/lib/egl/libGLESv1_CM_mali.so
01-20 13:58:19.481 13772-13772/com.example.ray.myoufd D/libEGL: loaded /system/lib/egl/libGLESv2_mali.so

                                                                [ 01-20 13:58:19.486 13772:13772 E/         ]
                                                                Device driver API match
                                                                Device driver API version: 29
                                                                User space API version: 29 


                                                                [ 01-20 13:58:19.486 13772:13772 E/         ]
                                                                mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Tue Jul 22 19:59:34 KST 2014 
01-20 13:58:19.531 13772-13772/com.example.ray.myoufd D/OpenGLRenderer: Enabling debug mode 0
01-20 13:58:20.646 13772-13772/com.example.ray.myoufd D/AbsListView: Get MotionRecognitionManager
01-20 13:58:20.656 13772-13772/com.example.ray.myoufd I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
01-20 13:58:20.656 13772-13772/com.example.ray.myoufd W/dalvikvm: VFY: unable to resolve virtual method 461: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
01-20 13:58:20.656 13772-13772/com.example.ray.myoufd D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
01-20 13:58:20.656 13772-13772/com.example.ray.myoufd I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
01-20 13:58:20.656 13772-13772/com.example.ray.myoufd W/dalvikvm: VFY: unable to resolve virtual method 483: Landroid/content/res/TypedArray;.getType (I)I
01-20 13:58:20.656 13772-13772/com.example.ray.myoufd D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002

0 个答案:

没有答案