找不到Symbol类ActionBarActivity(Android回收视图) [英] cannot find Symbol class ActionBarActivity (Android Recycled View)
问题描述
我在构建graddle时遇到了一些问题。.我不知道问题出在哪里,我读了很多有关此事的文章,但是我找不到解决方法。.
i已经:下载存储库
,放入依赖项和最新SDK版本
。
我尝试在 HomeActivity.xml
中制作 CardView
。我也有 MyViewHolder.java
, PageAdapter.java
和`MyObject.java,所以..我需要一些帮助
如果你想要另一个文件,我做了3 TabLayout。该代码在MainActivity.java中。
信息:Gradle任务[clean,:app:assembleDebug]
的完整输出pre>
C:\ ...... ..... \HomeActivity.java
错误:(16,35)错误:找不到符号类ActionBarActivity
错误:(26,5)错误:方法未覆盖或实现以下方法:一个超类型
错误:(28,9)错误:找不到符号变量super
错误:(29,9)错误:找不到符号方法setContentView(int)
C:\Users \cozakk\AndroidStudioProjects\MaximeBodivitVisionApp\app\src\main\java\com\maximebodivit\maximebodivitvisionapp\PagerAdapter.java
错误:(21,24)错误:类型不兼容:HomeActivity无法转换为片段
错误:任务':app:compileDebugJavaWithJavac'的执行失败。
>编译失败;有关详细信息,请参见编译器错误输出。
信息:26秒内无法建立
信息:6个错误
信息:0警告
信息:请参阅控制台
在此文件中,我有
ActionBarActivity
,onCreate
,红色的setContentView
...
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;
/ **
*由cozakk创建于2018年2月13日。
* /
公共类HomeActivity扩展了ActionBarActivity {
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
return inflater.inflate (R.layout.fragment_home,container,false);
}
私人RecyclerView recyclerView;
私人列表< MyObject>城市=新的ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_home);
//填满城市
ajouterVilles();
recyclerView =(RecyclerView)recyclerView.findViewById(R.id.recyclerView);
recyclerView.setAdapter(new MyAdapter(cities));
}
private void ajouterVilles(){
city.add(new MyObject( France, http://www.telegraph.co.uk/travel/destination /article130148.ece/ALTERNATES/w620/parisguidetower.jpg));
city.add(new MyObject( Angleterre, http://www.traditours.com/images/Photos%20Angleterre/ForumLondonBridge.jpg));
city.add(new MyObject( Allemagne, http://tanned-allemagne.com/wp-content/uploads/2012/10/pano_rathaus_1280.jpg));;
city.add(new MyObject( Espagne, http://www.sejour-linguistique-lec.fr/wp-content/uploads/espagne-02.jpg));
city.add(new MyObject( Italie, http://retouralinnocence.com/wp-content/uploads/2013/05/Hotel-en-Italie-pour-les-Vacances2.jpg)) ;
city.add(new MyObject( Russie, http://www.choisir-ma-destination.com/uploads/_large_russie-moscou2.jpg));;
}
}
Android Manifeste.xml
<?xml version = 1.0 encoding = utf-8?>
<清单xmlns:android = http://schemas.android.com/apk/res/android
package = com.maximebodivit.maximebodivitvisionapp>
<应用程序
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>
<活动
android:name =。MainActivity
android:label = @ string / app_name
android:theme = @ style / AppTheme.NoActionBar> ;
<意图过滤器>
< action android:name = android.intent.action.MAIN />
< category android:name = android.intent.category.LAUNCHER />
< / intent-filter>
< / activity>
< activity android:name =。SplashScreenActivity>< / activity>
< / application>
< / manifest>
解决方案根据文档'ActionBarActivity'已弃用,并从支持库中删除,将您的Activity从而是使用 AppCompatActivity:
import android.support.v7.app.AppCompatActivity;
公共类YourActivity扩展了AppCompatActivity
app / build.gradle
android {
compileSdkVersion 27
buildToolsVersion '27 .0.3'
defaultConfig {
applicationId 'your_app_id'
minSdkVersion 16
targetSdkVersion 27
版本代码1
版本名称 1.0
}
}
依赖项{
实现'com.android.support:appcompat-v7:27.1.0'
}
I have some problem when i build graddle.. i don't understand where is the probleme, i read many things about that, but i can't find the solution.. i have already: download the
Repository
, put in the dependencies and thelatest SDK version
.I try to make
CardView
in theHomeActivity.xml
. I have alsoMyViewHolder.java
,PageAdapter.java
and `MyObject.java so.. i need some help If you want the other file, i have made 3 TabLayout . the code is in the 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
In this file i have
ActionBarActivity
,onCreate
,setContentView
in red...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 Manifeste.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>
解决方案According to the documentation 'ActionBarActivity' has been deprecated and removed from support library, extend your Activity from 'AppCompatActivity' instead:
import android.support.v7.app.AppCompatActivity; public class YourActivity extends AppCompatActivity
app/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' }
这篇关于找不到Symbol类ActionBarActivity(Android回收视图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!