有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

当我单击片段页面时,java应用程序强制关闭

我设计了一个安卓应用程序的个人资料页面。但是,当我单击此页面时,它将强制关闭。如何防止撞车

Reference of my profile page

Resource files

res/布局/片段\剖面\ vp。xml

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

    <ScrollView
        安卓:layout_width="match_parent"
        安卓:layout_height="match_parent">

    <RelativeLayout
        安卓:layout_width="match_parent"
        安卓:layout_height="wrap_content">

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

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

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


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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

java/com。实例射线myoufd/Profile_副总裁。爪哇

package com.example.ray.myoufd;

import 安卓.os.Bundle;
import 安卓.support.v4.app.Fragment;
import 安卓.view.LayoutInflater;
import 安卓.view.View;
import 安卓.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。实例射线myoufd/主页。爪哇

package com.example.ray.myoufd;

import 安卓.graphics.Color;
import 安卓.os.Bundle;
import 安卓.support.v4.app.Fragment;
import 安卓.support.v4.view.ViewPager;
import 安卓.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);
    }

}

Stacktrace

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

01-20 13:58:19.006 13772-13772/? I/SELinux: Function: selinux_安卓_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_安卓_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 (L安卓/view/SearchEvent;)
01-20 13:58:19.076 13772-13772/com.example.ray.myoufd I/dalvikvm: Could not find method 安卓.view.Window$Callback.onSearchRequested, referenced from method 安卓.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: L安卓/view/Window$Callback;.onSearchRequested (L安卓/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 安卓.view.Window$Callback.onWindowStartingActionMode, referenced from method 安卓.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: L安卓/view/Window$Callback;.onWindowStartingActionMode (L安卓/view/ActionMode$Callback;I)L安卓/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 安卓.content.res.Resources.getDrawable, referenced from method 安卓.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: L安卓/content/res/Resources;.getDrawable (IL安卓/content/res/Resources$Theme;)L安卓/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 安卓.content.res.Resources.getDrawableForDensity, referenced from method 安卓.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: L安卓/content/res/Resources;.getDrawableForDensity (IIL安卓/content/res/Resources$Theme;)L安卓/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 安卓.content.res.TypedArray.getChangingConfigurations, referenced from method 安卓.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: L安卓/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 安卓.content.res.TypedArray.getType, referenced from method 安卓.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: L安卓/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) 个答案