gpt4 book ai didi

java - 找不到 Symbol 类 ActionBarActivity(Android 回收 View )

转载 作者:太空宇宙 更新时间:2023-11-03 12:14:13 25 4
gpt4 key购买 nike

我在构建 gradle 时遇到了一些问题..我不明白问题出在哪里,我读了很多关于那个的东西,但我找不到解决方案..我已经:下载Repository,放入依赖项和最新的SDK版本

我尝试在 HomeActivity.xml 中创建 CardView。我还有 MyViewHolder.javaPageAdapter.java 和 `MyObject.java 所以..我需要一些帮助如果你想要其他文件,我已经制作了 3 TabLayout 。代码在 MainActivity.java 中。

Information:Gradle tasks [clean, :app:assembleDebug]
C:\...........\HomeActivity.java
Error:(16, 35) error: cannot find symbol class ActionBarActivity
Error:(26, 5) error: method does not override or implement a method from a supertype
Error:(28, 9) error: cannot find symbol variable super
Error:(29, 9) error: cannot find symbol method setContentView(int)
C:\Users\cozakk\AndroidStudioProjects\MaximeBodivitVisionApp\app\src\main\java\com\maximebodivit\maximebodivitvisionapp\PagerAdapter.java
Error:(21, 24) error: incompatible types: HomeActivity cannot be converted to Fragment
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED in 26s
Information:6 errors
Information:0 warnings
Information:See complete output in console

在这个文件中,我有 ActionBarActivityonCreatesetContentView 红色...

HomeActivity.java

package com.maximebodivit.maximebodivitvisionapp;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

/**
* Created by cozakk on 13/02/2018.
*/

public class HomeActivity extends ActionBarActivity {

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_home, container, false);
}

private RecyclerView recyclerView;

private List<MyObject> cities = new ArrayList<>();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_home);

//Fill city
ajouterVilles();

recyclerView = (RecyclerView) recyclerView.findViewById(R.id.recyclerView);


recyclerView.setAdapter(new MyAdapter(cities));
}

private void ajouterVilles() {
cities.add(new MyObject("France","http://www.telegraph.co.uk/travel/destination/article130148.ece/ALTERNATES/w620/parisguidetower.jpg"));
cities.add(new MyObject("Angleterre","http://www.traditours.com/images/Photos%20Angleterre/ForumLondonBridge.jpg"));
cities.add(new MyObject("Allemagne","http://tanned-allemagne.com/wp-content/uploads/2012/10/pano_rathaus_1280.jpg"));
cities.add(new MyObject("Espagne","http://www.sejour-linguistique-lec.fr/wp-content/uploads/espagne-02.jpg"));
cities.add(new MyObject("Italie","http://retouralinnocence.com/wp-content/uploads/2013/05/Hotel-en-Italie-pour-les-Vacances2.jpg"));
cities.add(new MyObject("Russie","http://www.choisir-ma-destination.com/uploads/_large_russie-moscou2.jpg"));
}
}

Android list .xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.maximebodivit.maximebodivitvisionapp">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SplashScreenActivity"></activity>
</application>

</manifest>

最佳答案

根据documentation “ActionBarActivity”已被弃用并从支持库中删除,改为从“AppCompatActivity”扩展您的 Activity :

import android.support.v7.app.AppCompatActivity;

public class YourActivity extends AppCompatActivity

应用程序/build.gradle

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId 'your_app_id'
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"

}
}

dependencies {
implementation 'com.android.support:appcompat-v7:27.1.0'
}

关于java - 找不到 Symbol 类 ActionBarActivity(Android 回收 View ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48776962/

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