editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (noteid != -1) {
MainActivity.notes.set(noteid, String.valueOf(charSequence));
MainActivity.arrayAdapter.notifyDataSetChanged();
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});
neste código, noteid é basicamente argumentos retirados, que estão sendo colocados no recuo ou passados pelo recuo.
Intent intent = getIntent();
noteid = intent.getIntExtra("noteid", -1);
o código do lado negativo é basicamente o código extra, se você quiser entender mais claramente.
how to make the menu or insert the menu in our code ,
create the menu folder this the folder created by going into the raw
->rightclick->
directory->name the folder as you wish->
then click on the directory formed->
then click on new file and then name for file as you wish ie the folder name file
and now type the 2 lines code in it and see the magic.
Com o novo código de atividade chamado NoteEditor.java para fins de edição, meu aplicativo é basicamente o aplicativo de anotações.
package com.example.elavi.notes;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.Toast;
import static android.media.CamcorderProfile.get;
public class NoteEditorActivity extends AppCompatActivity {
EditText editText;
int noteid;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_note_editor);
editText = findViewById(R.id.editText);
Intent intent = getIntent();
noteid = intent.getIntExtra("noteid", -1);
if (noteid != -1) {
String text = MainActivity.notes.get(noteid);
editText.setText(text);
Toast.makeText(getApplicationContext(),"The arraylist content is"+MainActivity.notes.get(noteid),Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getApplicationContext(),"Here we go",Toast.LENGTH_SHORT).show();
MainActivity.notes.add("");
noteid=MainActivity.notes.size()-1;
}
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (noteid != -1) {
MainActivity.notes.set(noteid, String.valueOf(charSequence));
MainActivity.arrayAdapter.notifyDataSetChanged();
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});
}
}
starting waiting blocking gc alloc
esse tipo de erro, que pode até causar travamentos e travamentos. seguro e recomendado pelo google agora ..