使用x5cloud云平台来做网络彩讯-------------界面传值(七)

在涉及到界面传值问时,这个这不能马虎、

大多人会用到Intent,比如:

Intent intent = new Intent(Android_X5_SOSO_9Activity.this,B.class);
					String passString = "hello,b";
					intent.putExtra("passString", passString);
					startActivityForResult(intent, 0);

 接收时,就这样:

 intent = getIntent();
		String result = intent.getStringExtra("passString");

 当然也有需要返回的:

Intent intent = new Intent(B.this,Android_X5_SOSO_9Activity.class);
				String passString = "Hello,this is B";
				intent.putExtra("passStringB", passString);
				setResult(RESULT_OK, intent);

 

而最开始的页面则需要:

 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    	switch (resultCode) { 
    	case RESULT_OK:
    	Bundle b=data.getExtras();  
    	String str=b.getString("FromB");
    	TextView view = (TextView)findViewById(R.id.textA);
    	view.setText(str);
    	        break;
    		default:
    	        break;
    	}
    	}

 

你可能感兴趣的:(android,intent,x5cloud)