在android中切换活动

时间:2013-09-28 10:31:10

标签: android android-intent

我点击第一个活动的代码是

b.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        String text=e1.getText().toString();
        Intent i=new Intent(getApplicationContext(), editview.class);
        i.putExtra("mytext", text);
        CustomListViewAndroidExample.this.startActivity(i);
    }
});

和第二个活动代码是

et1=(EditText)findViewById(R.id.editText1);
et1.setText(getIntent().getStringExtra("mytext"));

2 个答案:

答案 0 :(得分:0)

使用以下代码:

 @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            String text=e1.getText().toString();
            Intent i=new Intent(CustomListViewAndroidExample.this, editview.class);
            i.putExtra("mytext", text);
            startActivity(i);
        }
    });

答案 1 :(得分:0)

尝试获取信息

Intent intent = new Intent();
    intent = getIntent();
    Bundle bundle = intent.getExtras();
    language = bundle.getString("Language");

将其设置为

  language="bla";
    intent.putExtra("Language", language);
            startActivity(intent);