нередактируется программно экран

Рейтинг: 0Ответов: 0Опубликовано: 21.02.2023

значит так такая проблема никак неизменяется экран, какой бы я элемент не скрывал, удалял или добавлял всо запускается как было в разметке

код

class EditActivity : AppCompatActivity() {
private val bd by lazy { notesdb.notedbfunc(this).gdao() }

private val noterep: NoteRepository by lazy { repositoryimp(bd) }
private lateinit var binding : ActivityEditBinding
private var namenotetext = ""
private var notetext = ""
private lateinit var notes: note
private var notesdata: Boolean = false
private var newnote: Boolean = false
private var note : Boolean = true
fun microfonefun(view: View){
    binding.nameplaintext.background = getDrawable(R.drawable.edittext)
    binding.noteplaintext.background = getDrawable(R.drawable.edittext)
    binding.nameplaintext.setOnClickListener{
        var intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault())
        startActivityForResult(intent,0)
        binding.nameplaintext.background = null
        binding.noteplaintext.background = null
    }
    binding.noteplaintext.setOnClickListener {
        var intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault())


    startActivityForResult(intent,1)
        binding.nameplaintext.background = null
        binding.noteplaintext.background = null
    }
}
    fun back(view: View) {
    if (note) {
        lifecycleScope.launch {
            if (newnote) {
                notes.namenote = binding.nameplaintext.text.toString()
                notes.note = binding.noteplaintext.text.toString()
                noterep.update(notes)
                finish()
            } else {
                if (binding.nameplaintext.text.toString() != "" || binding.noteplaintext.text.toString() != "") {
                    var note = note(
                        null,
                        binding.nameplaintext.text.toString(),
                        binding.noteplaintext.text.toString()
                    )
                    noterep.insert(note)
                }
                finish()
            }
        }
    }
    else{
        finish()
    }

}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if(resultCode == RESULT_OK && data != null){
        if (requestCode == 0) {
            val voice: ArrayList<String>? = data?.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS) as ArrayList<String>
            binding.nameplaintext.setText(binding.nameplaintext.text.toString() + " " + voice?.get(0))
        }
        if (requestCode == 1) {
            val voice: ArrayList<String>? = data?.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS) as ArrayList<String>
            binding.noteplaintext.setText(binding.noteplaintext.text.toString() + " " + voice?.get(0))
        }
    }
}
override fun onBackPressed() {
    backbutton.performClick()
}

}

разметка

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/editlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".EditActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="66dp">

        <Button
            android:id="@+id/backbutton"
            android:layout_width="58dp"
            android:layout_height="match_parent"
            android:background="@android:color/transparent"
            android:onClick="back"
            app:icon="?attr/actionModeCloseDrawable"
            app:iconTint="#000000"
            tools:ignore="SpeakableTextPresentCheck" />

        <EditText
            android:id="@+id/nameplaintext"
            android:layout_width="312dp"
            android:layout_height="match_parent"
            android:ems="10"
            android:hint="Заголовок"
            android:inputType="text" />

        <Button
            android:id="@+id/button"
            android:layout_width="43dp"
            android:layout_height="match_parent"
            android:layout_marginBottom="1dp"
            android:background="@android:color/transparent"
            android:text="Button"
            app:icon="@drawable/free_icon_microphone_3364184"
            app:iconGravity="top"
            app:iconSize="35dp"
            app:iconTint="#000000"
            tools:ignore="TextContrastCheck,TouchTargetSizeCheck" />

    </LinearLayout>

    <FrameLayout
        android:id="@+id/framelayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <MultiAutoCompleteTextView
            android:id="@+id/noteplaintext"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:autoLink="all"
            android:filterTouchesWhenObscured="false"
            android:fitsSystemWindows="false"
            android:gravity="start"
            android:hint="Заметка"
            android:visibility="invisible" />

        <LinearLayout
            android:id="@+id/linearlistlayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:visibility="invisible">

            <ScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:ignore="SpeakableTextPresentCheck">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <CheckBox
                        android:id="@+id/checkBox3"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="CheckBox" />
                </LinearLayout>
            </ScrollView>

            <Button
                android:id="@+id/button3"
                android:layout_width="113dp"
                android:layout_height="140dp"
                android:layout_weight="1"
                android:text="Button" />

        </LinearLayout>
    </FrameLayout>
</LinearLayout>

Ответы

Ответов пока нет.