I\'m trying to display data from my database in a ListFragment. To do this, I have followed the same way when I use ListActivity, created my own adapter (adapter might look
You should return the view from getview() function. You are returning "Null".
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = inflater.inflate(R.layout.company_list_item, parent, false);
Company company = (Company) getItem(position);
TextView nameView = (TextView) row.findViewById(R.id.CompanyListName);
TextView telephoneView = (TextView) row.findViewById(R.id.CompanyListTelephone);
TextView addressView = (TextView) row.findViewById(R.id.CompanyListAddress);
nameView.setText(company.name);
telephoneView.setText(company.telephone);
addressView.setText(company.address);
return row;//changed from null
}
Note: Use recycled view and Holders to make the listview scroll smooth. For beter understanding read this tutorial.