{"id":264,"date":"2016-09-01T09:49:08","date_gmt":"2016-09-01T09:49:08","guid":{"rendered":"http:\/\/www.josejavierfm.es\/blog\/?p=264"},"modified":"2016-09-28T10:11:24","modified_gmt":"2016-09-28T10:11:24","slug":"presentar-un-input-text-con-texto-cargado-en-android","status":"publish","type":"post","link":"https:\/\/www.josejavierfm.es\/blog\/2016\/09\/01\/presentar-un-input-text-con-texto-cargado-en-android\/","title":{"rendered":"Presentar un input text con texto cargado en Android"},"content":{"rendered":"<p>Para presentar una ventana con una caja de texto y poner un texto por defecto:<\/p>\n<pre>\nprivate void preguntaTexto(){<br \/>\n\t\t AlertDialog.Builder alert = new AlertDialog.Builder(this);<\/p>\n<p>\t\t alert.setTitle(getString(R.string.titulosms));<br \/>\n\t\t alert.setMessage(getString(R.string.telefonosms));<\/p>\n<p>\t\t \/\/ Set an EditText view to get user input<br \/>\n\t\t final EditText input = new EditText(this);<\/p>\n<p>\t         input.setText(\"TEXTO_QUE_QUEREMOS CARGAR\");<br \/>\n\t\t alert.setView(input);<\/p>\n<p>\t\t alert.setPositiveButton(\"Ok\", new DialogInterface.OnClickListener() {<br \/>\n\t\t public void onClick(DialogInterface dialog, int whichButton) {<br \/>\n\t\t   String textorecuperado= input.getText().toString();<br \/>\n\t\t   \/\/aqui hacemos lo que queramos con el texto que el usuario ha introducido<\/p>\n<p>\t\t });<\/p>\n<p>\t\t alert.setNegativeButton(\"Cancel\", new DialogInterface.OnClickListener() {<br \/>\n\t\t   public void onClick(DialogInterface dialog, int whichButton) {<br \/>\n\t\t     \/\/ No hacemos nada<br \/>\n\t\t   }<br \/>\n\t\t });<\/p>\n<p>\t\t alert.show();<br \/>\n\t }<\/p>\n<p>------------------------------------<br \/>\n @Override<br \/>\n    public void onAttachedToWindow() {<br \/>\n        openOptionsMenu();<br \/>\n    };<\/p>\n\n<div class=\"twitter-share\"><a href=\"https:\/\/twitter.com\/intent\/tweet?via=josejavierfm\" class=\"twitter-share-button\">Twittear<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Para presentar una ventana con una caja de texto y poner un texto por defecto: private void preguntaTexto(){ AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(getString(R.string.titulosms)); alert.setMessage(getString(R.string.telefonosms)); \/\/ Set an EditText view to get user input final EditText input = new EditText(this); input.setText(\u00abTEXTO_QUE_QUEREMOS CARGAR\u00bb); alert.setView(input); alert.setPositiveButton(\u00abOk\u00bb, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/posts\/264"}],"collection":[{"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/comments?post=264"}],"version-history":[{"count":3,"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/posts\/264\/revisions"}],"predecessor-version":[{"id":267,"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/posts\/264\/revisions\/267"}],"wp:attachment":[{"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/media?parent=264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/categories?post=264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/tags?post=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}