Reputation: 10318
How come I'm getting this error when I try to declare a Fragment in XML?
<fragment android:name="com.example.news.ArticleListFragment"
android:id="@+id/list"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" />
"Cannot resolve symbol: ArticleListFragment"??
Code file name ArticleListFragment.java
package com.example.myapp5;
import android.app.Fragment;
import android.app.Fragment;
import android.os.Bundle;
import android.view.View;
public class ArticleListFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
}
}
Upvotes: 5
Views: 12814
Reputation: 2373
I don't know if this completely answers your question, but it sounds like something just isn't set up properly. I have included an example that should illustrate what your File Explorer should look like given you are running Android Studio (It will still look similar to this in Eclipse).
Now, you need to make sure everything in android:name
looks right here, but for your package.
Upvotes: 6
Reputation: 1546
You use com.example.news.ArticleListFragment
as fully qualified class name, but the real name of your class is com.example.myapp5.ArticleListFragment
, because you have created it in different package than the tutorial.
So you should use
android:name="com.example.myapp5.ArticleListFragment"
Upvotes: 4