Edit (19/4) I'm attaching a dropbox link, because the first error was fixed, but still the app crashes without a reason, it goes from the looper to the ZygotInit to kill the app, But I can't seem to find the reason nor the logcat gives any... https://www.dropbox.com/sh/2hrzqk9jnrlro0m/471jspyoCl
EDIT: The fragment_news_feed.xml: is the problematic one below... The ListFragment is pretty long since it also contains asynctask, attching only the overrides:
View feedView; ListView mRssFeed; ArrayAdapter<String> rssListAdapter; List<String> rssItemList; public NewsFeed() { } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Read in the flag indicating whether or not the user has demonstrated awareness of the // drawer. See PREF_USER_LEARNED_DRAWER for details. SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); //mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); if (savedInstanceState != null) { //mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); //mFromSavedInstanceState = true; } rssItemList = new ArrayList<>(); rssItemList.add("T"); rssListAdapter = new ArrayAdapter<>(getActivity(), R.layout.fragment_news_feed, R.id.item, rssItemList); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like to influence the set of actions in the action bar. setHasOptionsMenu(true); mRssFeed = getView().getListView(); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { feedView = inflater.inflate(R.layout.fragment_news_feed, container, false); //mRssFeed = getView().getListView(); /*String rss = ""; try { rss = getRssFeed(); rssItemList.clear(); rssItemList.add(rss); rssListAdapter.add(rss); mRssFeed.setAdapter(rssListAdapter); } catch (Exception ex) { Log.w("My News", "Exception Caught: " + ex.toString()); }*/ return feedView; } @Override public void onStart() { super.onStart(); new GetRssFeedTask().execute(); }
ORIGINAL: I'm writing a little application, with two fragments (one Fragment and one ListFragment) and two layouts (one of them is in one of the fragments).
The First fragment is:
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#cccc"
tools:context="com.kfir.bs.mynews.mynews.NavigationDrawerFragment" />
With onCreateView that works fine!!
The problematic fragment is the layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.kfir.bs.mynews.mynews.NewsFeed$PlaceholderFragment">
<ListView
android:id="@+id/feedlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
</RelativeLayout>
the onCreateView for the second fragment is:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
feedView = inflater.inflate(R.layout.fragment_news_feed, container, false);
mRssFeed = (ListView) feedView.findViewById(R.id.feedlist);
// TODO here I need to reed the RSS and inflate the list with data
String rss = "";
try {
rss = getRssFeed();
rssItemList.clear();
rssItemList.add(rss);
rssListAdapter.add(rss);
mRssFeed.setAdapter(rssListAdapter);
}
catch (Exception ex) {
Log.w("My News", "Exception Caught: " + ex.toString());
}
return feedView;
}
I'm working with Android Studio, with gradle. The build is smooth as butter,BUT... when I run the app, when it gets to the secong onCreateView (shown above), The application cllapses with runTime Exeption Error:
java.lang.RuntimeException: Content has view with id attribute 'android.R.id.list' that is not a ListView class
Although I got my layout inflated, and the list taken care of, I still get the exception.
What can be the problem?
Thanks i nadvance, K.
You need to change this
android:id="@+id/feedlist"
to
android:id="@android:id/list"
In onActivityCreated
mRssFeed = getView().getListView();
Or change
extends ListFragment
to
extends Fragment
Keep the rest the same.