1

I have used ListFragment in that i have used below code

public class TestListFragment extends ListFragment {

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),R.layout.list_column,
            R.layout.list_column, R.id.text, createDataList(1000));
    setListAdapter(adapter);
}

}

but i am getting stuck where The constructor ArrayAdapter(FragmentActivity, int, int, int, List) is undefined

i have searched it and found Getting a constructor error with ArrayAdapter in a ListFragment on Android same problem in that it is suggesting me that use getActivity() and i have used that but still eclipse don't allow me

1
  • must sure your FragmentActivity imported as a android.support.v4.FragmentActivity Commented Dec 5, 2013 at 13:46

2 Answers 2

2

There is no constructor such as

ArrayAdapter<String>(FragmentActivity, int, int, int, List<String>)

You should instantiate like this :

ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),R.layout.list_column, R.id.text, createDataList(1000));

You can check the constructors available at the official docs site.

Sign up to request clarification or add additional context in comments.

1 Comment

@Naveen N, please stop defacing my posts.
1

If you are using Sherlock fragment... then instead of getActivity(), use, getSherlockActivity();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.