![](/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.