当我建立渐变时我遇到了一些问题..我不明白问题在哪里,我读了很多关于这个的事情,但我无法找到解决方案..
我已经:下载Repository
,输入依赖项和latest SDK version
。
我尝试在CardView
中制作HomeActivity.xml
。我还有MyViewHolder.java
,PageAdapter.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
在此文件中,我有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;
/**
* 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>
答案 0 :(得分:4)
根据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'
}
答案 1 :(得分:2)
答案 2 :(得分:1)
ActionBarActivity 已从支持库中删除。请看一下:
您可以通过将ActionBarActivity更改为 AppCompatActivity 轻松解决问题。