0

我有一个奇怪的问题,当我打开某个片段时,我的应用程序会自动将我注销。我什至尝试注释掉所有代码以阻止这种情况发生,但问题仍然存在。我已经为片段包含了我的空类和 XML。我只能假设这是我忽略的一个愚蠢的问题,但我已经尝试找到答案好几天了。

感谢任何帮助

fragment_edit_profile

<merge 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">


<ScrollView android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="16dp">
    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:id="@+id/profileImage"
        android:layout_marginTop="25dp"
        android:layout_centerHorizontal="true"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/profileImage"
        android:layout_centerHorizontal="true"
        android:text="Change profile picture"
        android:textSize="18sp"
        android:id="@+id/changeProfilePictureTextView"/>


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_marginTop="50dp"
        android:layout_below="@id/changeProfilePictureTextView"
        android:background="@drawable/white_and_grey_border_bottom"
        android:id="@+id/relativeLayout1">

        <ImageView
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:background="@drawable/ic_action_compose"
            android:layout_centerVertical="true"/>

        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginStart="45dp"
            android:id="@+id/usernameEditTextEditProfile"
            android:hint="@string/change_username"/>

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_marginTop="50dp"
        android:layout_below="@id/relativeLayout1"
        android:background="@drawable/white_and_grey_border_bottom"
        android:id="@+id/relativeLayout2">

        <ImageView
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:background="@drawable/ic_action_compose"
            android:layout_centerVertical="true"/>

        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginStart="45dp"
            android:hint="Change email address"
            android:id="@+id/emailEditTextEditProfile"/>

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_marginTop="50dp"
        android:layout_below="@id/relativeLayout2"
        android:background="@drawable/white_and_grey_border_bottom"
        android:id="@+id/relativeLayout3">

        <ImageView
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:background="@drawable/ic_action_compose"
            android:layout_centerVertical="true"
            android:id="@+id/imageView" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="45dp"
            android:layout_centerVertical="true"
            android:text="Click here to reset password"
            android:textStyle="italic"
            android:textSize="18sp"
            android:id="@+id/changePassword"/>
    </RelativeLayout>

    </RelativeLayout>

 </ScrollView>

EditPrfileFragment

public class EditProfileFragment extends Fragment implements         View.OnClickListener {


private static final String TAG = "EditProfileFragment";
String password;
String passwordConfirm;
private EditText passwordEditText;
private EditText passwordConfirmEditText;

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_edit_profile, container, false);

    return view;
}

@Override

public void onClick(View v) {
}
4

1 回答 1

0

用下面的代码替换您的代码。

<ScrollView 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">
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="16dp">
    <ImageView
        android:id="@+id/profileImage"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="25dp" />
    <TextView
        android:id="@+id/changeProfilePictureTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/profileImage"
        android:layout_centerHorizontal="true"
        android:text="Change profile picture"
        android:textSize="18sp" />
    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_below="@id/changeProfilePictureTextView"
        android:layout_marginTop="50dp"
        android:background="@drawable/white_and_grey_border_bottom">
        <ImageView
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_centerVertical="true"
            android:background="@drawable/ic_action_compose" />
        <EditText
            android:id="@+id/usernameEditTextEditProfile"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginStart="45dp"
            android:hint="@string/change_username"
            tools:ignore="RtlCompat" />
    </RelativeLayout>
    <RelativeLayout
        android:id="@+id/relativeLayout2"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_below="@id/relativeLayout1"
        android:layout_marginTop="50dp"
        android:background="@drawable/white_and_grey_border_bottom">
        <ImageView
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_centerVertical="true"
            android:background="@drawable/ic_action_compose" />
        <EditText
            android:id="@+id/emailEditTextEditProfile"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginStart="45dp"
            android:hint="Change email address"
            tools:ignore="RtlCompat" />
    </RelativeLayout>
    <RelativeLayout
        android:id="@+id/relativeLayout3"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_below="@id/relativeLayout2"
        android:layout_marginTop="50dp"
        android:background="@drawable/white_and_grey_border_bottom">
        <ImageView
            android:id="@+id/imageView"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_centerVertical="true"
            android:background="@drawable/ic_action_compose" />
        <TextView
            android:id="@+id/changePassword"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginStart="45dp"
            android:text="Click here to reset password"
            android:textSize="18sp"
            android:textStyle="italic"
            tools:ignore="RtlCompat" />
    </RelativeLayout>

 </RelativeLayout>
 </ScrollView>
于 2019-03-20T18:09:12.003 回答