• Activity间的跳转和数据传递


    	Button bt;
            EditText et;
    	TextView tv;
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		// TODO Auto-generated method stub
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.sendimpl);
    		bt=(Button) findViewById(R.id.mybut);
    		et=(EditText) findViewById(R.id.etqq);
    		tv=(TextView) findViewById(R.id.tvdd);
    		bt.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				String valueString=et.getText().toString();
    				Intent t=new Intent(SendImpl.this,ReviceImpl.class);
    				t.putExtra("value", valueString);
    				startActivityForResult(t, 1);
    			}
    		});
    	}
    	@Override
    	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    		if(resultCode==RESULT_OK){
    			
    			String valString=data.getStringExtra("val");
    			tv.setText(valString);
    			
    		}else{
    			tv.setText("取消操作");
    		}
    	}
    

      

    	TextView tv;
    	Button bu;
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		// TODO Auto-generated method stub
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.recevie);
    		tv=(TextView) findViewById(R.id.tvqq);
    		bu=(Button) findViewById(R.id.retbut);
    		Intent t=getIntent();
    		String vaString=t.getStringExtra("value");
    		tv.setText(vaString);
    		
    		bu.setOnClickListener(new OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				getIntent().putExtra("val", "second reslut");
    				setResult(RESULT_OK,getIntent());
    				finish();
    			}
    		});
    	}
    

      

  • 相关阅读:
    API
    MVC判断是否登录
    MVC收藏店铺
    MVC显示界面
    MVC登录
    MVC登录跳转到显示
    MVC退单
    MVC判断登录
    Oracle 千位符转换,及格式转换
    【转】Java 服务端 和 C# 客户端 实现 Socket 通信
  • 原文地址:https://www.cnblogs.com/ch123456/p/6964421.html
Copyright © 2020-2023  润新知