【问题标题】:toast cannot be resolved and activitynotfoundexception cannot be resolved to a typetoast 无法解析,activitynotfoundexception 无法解析为类型
【发布时间】:2013-12-14 12:11:24
【问题描述】:

我想在我的应用中导入谷歌地图。

这是代码: public static void maps(Activity 活动,字符串地址) {

try {

    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?q=" + address));
    activity.startActivity(intent);

} catch (ActivityNotFoundException e) {
    Toast.makeText(activity, activity.getString(R.id.webView), Toast.LENGTH_SHORT).show();
}
}

public static void navigation(Activity activity, String address) {

try {

    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" +       address));
    activity.startActivity(intent);

} catch (ActivityNotFoundException e) {

    Toast.makeText(activity, activity.getString(R.id.webView), Toast.LENGTH_SHORT).show();
}
}

我得到 2 个错误。 ActivityNotFoundException 无法解析为类型,Toast 无法解析。

这怎么可能?

谢谢。

【问题讨论】:

    标签: android google-maps exception toast


    【解决方案1】:

    这是因为缺少导入语句..通过在 Eclipse 中按 ctrl+shift+o 导入这些包。 或在标题部分添加这些包..

    【讨论】:

      猜你喜欢
      • 2015-10-22
      • 1970-01-01
      • 2021-08-28
      • 2012-11-22
      • 2015-06-10
      • 2014-07-23
      • 2011-12-31
      • 2012-09-27
      • 2017-07-12
      相关资源
      最近更新 更多