![](/img/trans.png)
[英]Intent.putExtra(String,Bundle) vs Intent.putExtra(Bundle)
[英]putExtra String Intent Android
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
m = lv.getAdapter().getItem(info.position).toString();
Toast.makeText(getBaseContext(), "You clicked !"+m, Toast.LENGTH_SHORT).show();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to delete this Fixture?");
builder.setCancelable(false);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//listAdapter.remove(m);
Intent i = new Intent(Afc.this.getApplicationContext(), WebViewExample.class);
i.putExtra("Key", m);
startActivity(i);
}
//新課程活動WebView /////////////
Bundle extras = getIntent().getExtras();
String addOn = extras.getStringExtra("key",m);
Toast.makeText(getBaseContext(), "You clicked !"+addOn, Toast.LENGTH_SHORT).show();
嗨我傳遞一個帶有意圖的字符串,它在變量m的新活動中給出了一個錯誤,在getStringExtra(“key”,m);中。 有人可以幫忙嗎?
我這樣做是對的嗎?
putExtra的關鍵是區分大小寫。 有一次你使用
鍵
在另一個
鍵
在這兩種情況下都應該使用密鑰或密鑰。
在任何情況下都使用getStringExtra(“key”)而不是getStringExtra(“key”,m)。 正如您在d ocumentation中所看到的,沒有getStringExtra方法接受兩個參數。 解釋一下:你的變量m無法解析,因為你剛剛在第一個類中聲明了它,而在第二個類中沒有聲明。
是和getStringExtra(“key”,m); ??? 是錯誤的USE getStringExtra(“key”);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.