原因是,我填寫我的用戶名和密碼,然後單擊登錄按鈕它在頁面上再次加載需要tu填寫用戶名和密碼這裏是我的源代碼意圖不通過我我的第二個活動
public class MainActivity extends Activity {
private EditText mTextUserName;
private EditText mTextPassword;
public String user_name;
public String pass_word;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextUserName = (EditText) findViewById(R.id.textUserName);
mTextPassword = (EditText) findViewById(R.id.textPassword);
final Button mButtonLogin = (Button) findViewById(R.id.buttonLogin);
mButtonLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
user_name = mTextUserName.getText().toString();
pass_word = mTextPassword.getText().toString();
// i am passing this intent
Intent goToNextActivity = new Intent(getApplicationContext(), ViewActivity.class);
goToNextActivity.putExtra("username", user_name);
goToNextActivity.putExtra("password", pass_word);
startActivity(goToNextActivity);
}
});
}
,並在礦山ViewActivity也
public class ViewActivity extends Activity {
private WebView webView;
public String pass_word;
public String user_name;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view);
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setUseWideViewPort(true);
webView.setScrollbarFadingEnabled(false);
webView.getSettings().setDefaultFontSize(20);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
//here i get them
getIntent().getStringExtra("username");
getIntent().getStringExtra("password");
webView.loadUrl("http://intranet.mdis.uz/");
}
但是這行的事作品((我spended 8小時的研究,但沒有任何幫助我
當你按下按鈕,你是不是要去ViewActivity?如果嘗試Intent goToNextActivity = new Intent(getActivity(),ViewActivity.class)會怎麼樣? – michaelcarrano 2014-10-31 18:30:10
目前尚不清楚你想要做什麼。你可以調用'getIntent()。getStringExtra(「username」);'getIntent()。getStringExtra(「password」);'但是不要對返回值做任何事情。 – MadEqua 2014-10-31 18:33:39
活動已更改的事實意味着用戶已再次登錄 – 2014-10-31 18:52:23