How do I insert the SQLite data into this listview of my code:
@Override
public void onActivityCreated(Bundle savedInstanceState) {
String[] sCheeseStrings = {"Emerson","Simone","Samara"};
super.onActivityCreated(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1,sCheeseStrings));
}
The data I want to display is 'TITLE' and 'AUTHOR'.
I'm trying this:
public class TabActivity extends Fragment {
private final DataBaseHandler db = new DataBaseHandler(getActivity());
public class TabActivity extends Fragment {
private final DataBaseHandler db = new DataBaseHandler(getActivity());
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
db.addBook(new Book("Android Application Development Cookbook", "Wei Meng Lee"));
db.addBook(new Book("Android Programming: The Big Nerd Ranch Guide", "Bill Phillips and Brian Hardy"));
db.addBook(new Book("Learn Android App Development", "Wallace Jackson"));
View rootView = inflater.inflate(R.layout.activity_tab, container, false);
return rootView;
List<Book> cursor = db.getAllBooks();
String title;
String author;
String[] from = { title, author };
int[] to = { android.R.id.text1, android.R.id.text1 };
SimpleCursorAdapter adapter = SimpleCursorAdapter( getActivity().getApplicationContext(), android.R.layout.simple_list_item_2, cursor, from, to);
}
}
But it is giving an error "The method SimpleCursorAdapter (Context, int, List, String [], int []) is undefined for the TabActivity type". What can it be?