我正在尝试从 editText 框中获取数据并在单击按钮时打开该 url。为此,我必须将数据从一个意图发送到另一个意图。为此,我已经提到了这个和这个但无法发送数据..我正在尝试将数据从主要发送到网络视图活动..
MainActivity.Java
public class MainActivity extends Activity {
Button b;
WebView mWebVIew2;
EditText mEdit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b = (Button) findViewById(R.id.button1);
mEdit = (EditText) findViewById(R.id.editText1);
final String s = mEdit.getText().toString();
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), mEdit.getText(), Toast.LENGTH_LONG).show();
Intent i = new Intent(getApplicationContext(), WebViewActivity.class);
i.putExtra("mSite", s);
startActivityForResult(i, 0);
}
});
}
}
WebViewActivity.java
public class WebViewActivity extends Activity {
private WebView mWebView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webv);
mWebView = (WebView) findViewById(R.id.webView1);
Intent mIntent = getIntent();
String y = mIntent.getExtras().getString("mSite");
Toast.makeText(getApplicationContext(), y, Toast.LENGTH_LONG).show();
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(y);
}
}