Why does the simple code below work in Android 3.0, but not in 2.3.3 ???
In 2.3.3, it shows only a blank screen.
There is no message in LogCat.
Any help would be appreciated.
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.widget.ArrayAdapter;
public class TestListFragment extends ListFragment {
private ArrayAdapter<String> myAdapter;
private String[] data = {"One", "Two", "Three"};
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
myAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, data);
setListAdapter(myAdapter);
}
}
Regards,
** EDIT
I found the cause. If the activity extends FragmentActivity, the code above works in 2.3.3, but if it extends ActionBarActivity it does not work.
Does someone know how to solve it ?
I think the workaround is jus not use the default android.R.id.content to show the fragment.
I just do this:
In the onCreate() of your activity(extends ActionBarActivity):
setContentView(R.layout.whocares); getSupportFragmentManager().beginTransaction().add(R.id.the_root_view,yourFragment).commit();