Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create Fragment ListActivity with compatibility package v4?

I've been trying to complete tutorial "Working with fragments" which was designed for android 3.0+

To acomplish that I'm using compatibility package v4 (since my API is 7). However I'm stuck on the lists. I couldn't find straight answer.

I'm getting a ClassNotFoundException. I inherited fragment class from FragmentActivity but what about my ListActivity? There is no such thing as FragmentListActivity and I think it keeps crashing at this.

Can I create Fragment ListActivity with compatibility package v4? Or it's not possible at all?

like image 831
Jacek Kwiecień Avatar asked Jun 07 '12 09:06

Jacek Kwiecień


2 Answers

Nope, doesn't exist. Stupid support library.

The solution is easy to create but tedious to maintain. Just copy the native ListActivity class into your project, rename it "FragmentListActivity", and let it extend FragmentActivity instead of Activity. No other tweaks are required and the copy is easy. If you are uncertain you can peak at my code, but it's always best to derive the latest.

Same goes for GridActivity I would say.

like image 50
pjv Avatar answered Oct 20 '22 08:10

pjv


Look at this question: What to do about ListActivity/MapActivity when converting to Fragments using the compatibility library?

There is a ListFragment.

like image 24
letonai Avatar answered Oct 20 '22 07:10

letonai