Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法在“从云firestore编辑文本”中设置文本?_Java_Android_Firebase_Google Cloud Firestore_Android Edittext - Fatal编程技术网

Java 无法在“从云firestore编辑文本”中设置文本?

Java 无法在“从云firestore编辑文本”中设置文本?,java,android,firebase,google-cloud-firestore,android-edittext,Java,Android,Firebase,Google Cloud Firestore,Android Edittext,打开便笺后,我会看到便笺标题和内容的文本视图。我想编辑笔记。但“编辑注释”活动存在问题。它只显示edittext中标题的文本。但以下内容未显示文本。我尝试了很多方法,比如我试着检查什么是问题,我把标题的数据放进去。但它也没有显示标题。表示上部标题编辑文本可以显示标题数据和内容数据,但第二个编辑文本不显示标题数据和内容数据 这是notes_公开课 public class notes_open extends AppCompatActivity { Intent data;

打开便笺后,我会看到便笺标题和内容的文本视图。我想编辑笔记。但“编辑注释”活动存在问题。它只显示edittext中标题的文本。但以下内容未显示文本。我尝试了很多方法,比如我试着检查什么是问题,我把标题的数据放进去。但它也没有显示标题。表示上部标题编辑文本可以显示标题数据和内容数据,但第二个编辑文本不显示标题数据和内容数据

这是notes_公开课

public class notes_open extends AppCompatActivity {
        Intent data;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_notes_open);
            Toolbar toolbar = findViewById(R.id.toolbar);
            setSupportActionBar(toolbar);
    
            getSupportActionBar().setDisplayShowHomeEnabled(true);
    
           data= getIntent();
            TextView MyTitle = findViewById(R.id.notesopentitle);
            TextView MyContent= findViewById(R.id.notesopencontent);
            MyContent.setMovementMethod(new ScrollingMovementMethod());
    
    
    
    
            MyTitle.setText(data.getStringExtra("ourtitle"));
            MyContent.setText(data.getStringExtra("ourcontent"));
    
    
    
            FloatingActionButton fab = findViewById(R.id.fab);
            fab.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                            .setAction("Action", null).show();
                }
            });
        }
        @Override
    
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            MenuInflater inflater= getMenuInflater();
            getMenuInflater().inflate(R.menu.notesopen, menu);
            return super.onCreateOptionsMenu(menu);
        }
        @Override
        public boolean onOptionsItemSelected(@NonNull MenuItem item) {
            switch(item.getItemId()){
                case  android.R.id.home:
                onBackPressed();
                case R.id.edit_note:
                    Intent i =  new Intent(getApplication(),edit_note.class);
                    i.putExtra("ourtitle",data.getStringExtra("ourtitle"));
                    i.putExtra("ourcontent",data.getStringExtra("ourcontent"));
                    startActivity(i);
            }
            return super.onOptionsItemSelected(item);
        }
    }
下面是编辑注释类

public class edit_note extends AppCompatActivity {
Intent data;
EditText edit_title,  edit_note;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_note);
        data =  getIntent();

        edit_title =  findViewById(R.id.edit_ttile);
        edit_note =  findViewById(R.id.edit_note);
        String edititle =  data.getStringExtra("ourtitle");
        String editcontent =  data.getStringExtra("ourcontent");
        try {


            edit_title.setText(edititle);
            edit_note.setText(editcontent);



}catch (NullPointerException ignore){}
    }
}
编辑注释xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".edit_note">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appBarLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay"
        tools:ignore="MissingConstraints">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </com.google.android.material.appbar.AppBarLayout>

    <EditText
        android:id="@+id/edit_ttile"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPersonName"
        android:hint="Title"
        android:layout_below="@id/appBarLayout2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        tools:layout_editor_absoluteY="56dp" />

    <EditText
        android:id="@+id/edit_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPersonName"
        android:hint="Content"
        android:layout_below="@id/edit_ttile"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        tools:layout_editor_absoluteY="56dp" />


</RelativeLayout>

您的编辑文本分配错误:

edit_note =  findViewById(R.id.edit_note);
相反,它需要:

edit_note =  findViewById(R.id.edit_content);

仍然不清楚,请发布img以理解并请检查这一点。如果您正在检索数据或否,您是否尝试进行控制台操作?您如何描述这一点?请检查您是否正在编辑注释活动中检索这两个值。哦,谢谢,伙计,您有很好的问题解决技能