Contenido sobre Android
Buscar
Social
Ofertas laborales ES

Foro sobre Android > intent


import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

public class MainActivity extends Activity {
/** Called when the activity is first created. */

protected LinearLayout layout,layout_02,layout_03,layout_04;
protected EditText Ctexto;
protected EditText Ctexto_02;
protected EditText Ctexto_03;
protected Button Boton_01;
protected Button Boton_02;
protected ArrayList<NewsItem> arrNewsList;
String something;
Intent intent;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = getIntent().getExtras();
//something = (String)bundle.getString("hola");
//setContentView(R.layout.main);
Resources resources = this.getResources();

this.initLayout();

/*intent.putExtra("hola", "holamundo¡¡¡¡¡");

Bundle bundle = getIntent().getExtras();
something = (String)bundle.getString("hola");
Boton_01.setText(something);
*/


this.Boton_01.setText(something);
Boton_01.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){

String texto = Ctexto.getText().toString().trim();

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(Ctexto.getWindowToken(), 0);
Ctexto_02.setText(texto);


/*String str = something;//texto.getText().toString();
Ctexto_02.setText(str);
Intent myIntent = new Intent(v.getContext(), Prueba.class);
myIntent.putExtra("key", "value");
startActivity(myIntent);*/

}
});

}
protected void initLayout()
{
TextView t = new TextView(this);
TextView t1 = new TextView(this);
this.layout = new LinearLayout(this);
this.layout_02 = new LinearLayout(this);
this.layout_03 = new LinearLayout(this);
this.layout_03 = new LinearLayout(this);
this.Boton_01 = new Button(this);
this.Boton_02 = new Button(this);
this.Ctexto = new EditText(this);
this.Ctexto_02 = new EditText(this);
ScrollView scroll = new ScrollView(this);
LinearLayout.LayoutParams dimension = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);

t1.setText("Nombre");
this.Ctexto.setLayoutParams(dimension);
layout_02.addView(t1);
layout_02.addView(Ctexto);

this.layout_02.setOrientation(LinearLayout.HORIZONTAL);
this.layout.setOrientation(LinearLayout.VERTICAL);
this.layout_03.setOrientation(LinearLayout.HORIZONTAL);

this.layout.addView(layout_02);
t.setText("Apellido");


layout_03.addView(t);
layout_03.addView(Ctexto_02);
this.Boton_01.setText("Enviar");
this.Boton_01.setLayoutParams(dimension);
layout_03.addView(Boton_01);

this.layout.addView(layout_03);

scroll.addView(layout);
this.setContentView(scroll);
}

}


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;


public class Prueba extends Activity {
Intent intent;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.respuesta_02);


intent.putExtra("hola", "holamundo");
intent.putExtra("keyy", "valor");

}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cl.ciisa.rq"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />





<category android:name="android.intent.category.LAUNCHER" />


</manifest>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>

noviembre 11, 2011 | Unregistered Commenterrquiroz

¿Y todos es tos post a que vienen?

noviembre 12, 2011 | Registered CommenterAbraham