gpt4 book ai didi

java - 错误 "main cannot be resolved or is not a field "

转载 作者:行者123 更新时间:2023-11-30 11:39:32 24 4
gpt4 key购买 nike

“主要内容无法解决或不在字段中”它在 setcontentview 的 mainactivity 中给出错误“main cannot be resolved or not in field.
这是我的代码请帮助我,因为我已经厌倦了寻找出路请重新删除此错误 “这是我的主要 Activity ”

package com.exampl.goglemaps;

import android.os.Bundle;
import com.exampl.goglemaps.R;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

public class MainActivity extends MapActivity {

@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.main);

//fetch the map view from the layout
MapView mapView = (MapView) findViewById(R.id.mapview);

//make available zoom controls
mapView.setBuiltInZoomControls(true);
}

@Override
protected boolean isRouteDisplayed() {

return false;

}
}

我的 manfiest 文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exampl.goglemaps"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="14" />

<uses-permission android:name="android.permission.INTERNET"/>

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>

这是我的xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="Your Google Maps API key"
android:clickable="true" />
</LinearLayout>

在 setContentView(R.layout.main) 中调用 mainactivity 时出错;说“main cannot be resoloved or in not a field” 我几乎搜索了每个论坛但都没有解决这个问题,请帮助我解决这个错误。

标题

提前致谢

最佳答案

我认为您应该使用 R.layout.MainActivity 代替 R.layout.main

关于java - 错误 "main cannot be resolved or is not a field ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13223464/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com