我需要帮助,请,我在fragment.kt中得到错误的过程中得到一个摄像头设置
**
//fragmentcamera.xml
**
**<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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=".MainActivity">
<androidx.camera.view.PreviewView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/preview"/>
<Button
android:id="@+id/btnTakePhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Take photo"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/btnDisplayGallery"
app:layout_constraintBottom_toBottomOf="parent"/>
<Button
android:id="@+id/btnDisplayGallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_marginBottom="300dp"
android:text="Display gallery"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/btnTakePhoto" />
</androidx.constraintlayout.widget.ConstraintLayout>**
以下是camerafragment.kt的图像
指令集
指令集
s的数据结构
我得到的错误
指令集
2条答案
按热度按时间ghhaqwfi1#
jljoyd4f2#
将所有“this,getApplicationContext”替换为getActivity()。在Java中
在Kotlin中,将所有“this,getApplicationContext”替换为活动。
两种可能的定义:
片段中的getActivity()会传回目前与片段相关联的活动。(请参阅http://developer.android.com/reference/android/app/Fragment.html#getActivity())。getActivity()是使用者定义的。