Guest User

Untitled

a guest
Dec 15th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. final RelativeLayout layout = (RelativeLayout) findViewById(R.id.ataque);
  2.  
  3. mas.setOnClickListener(new View.OnClickListener() {
  4. @Override
  5. public void onClick(View v) {
  6. EditText extra = new EditText(getApplicationContext());
  7. int ntext = mispreferencias.getInt("contadortext", 0);
  8. RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
  9. extra.setId(ntext);
  10. final int id_ = extra.getId();
  11. extra.setLayoutParams(p);
  12. editor.putInt("extra" + ntext, id_);
  13. editor.putInt("contadortext", ntext + 1);
  14. editor.commit();
  15. layout.addView(extra);
  16. }
  17. });
  18.  
  19. int ntext = mispreferencias.getInt("contadortext", 0);
  20.  
  21. for (int i = 0; i < ntext; i++) {
  22. int ide = mispreferencias.getInt("extra" + i, 0);
  23. EditText edi = (EditText) findViewById(ide);
  24. editor.putString("text" + i, edi.getText().toString());
  25. }
  26.  
  27. java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference
Add Comment
Please, Sign In to add comment