private Button btnLogin;
private EditText txtPub;
private EditText txtPriv;
final Context context = this;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loginfirst);
btnLogin = (Button)findViewById(R.id.btnEnter);
btnLogin.setOnClickListener(this);
txtPub = (EditText)findViewById(R.id.textPublic);
txtPriv = (EditText)findViewById(R.id.textPrivate);
}
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, WebViewActivity.class);
startActivity(intent);
}
WebViewActivity.class
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webView = (WebView) findViewById(R.id.web_view);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://url.com/txtpub+txtprive");
}
如何獲取 edittxt txtpub 和 txtpriv 的值,然後放進url的webviewactivity類中?我想把txtpub 和txtpriv 的值放入url中,怎麼實現呢?
String txtpubStr=txtPub.getText().toString();
Intent intent = new Intent(context, WebViewActivity.class);
intent.putExtra("txtPub", txtpubStr)
startActivity(intent);
然後在WebViewActivity中
Intent intent=getIntent();
String txtPub=intent.getStringExtra("txtPub")//注意這裡的"txtPub"與之前的要一致