我正在尝试从底部工作表中打开一个片段,但是当我运行应用程序并单击底部工作表中应该执行此操作的按钮时,应用程序崩溃。
显示的构建失败是:
此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 7.0 不兼容。使用“--warning-mode all”显示各个弃用警告。
如何从我的底页打开一个片段。先感谢您!
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
public class BottomSheet extends BottomSheetDialogFragment {
Button flood
FragmentManager fragmentManager;
FragmentTransaction fragmentTransaction;
public BottomSheet() {
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.bottom_sheet, container, false);
flood = v.findViewById(R.id.flood);
flood.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EmergencyContacts nextFrag= new EmergencyContacts();
getActivity().getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container, nextFrag, "findFragment")
.addToBackStack(null)
.commit();
}
});
return v;
} }
摇篮依赖:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-firestore:17.1.2'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.material:material:1.3.0-alpha02'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}