[Java for Android App Development] JoshieGeek:
Hi I have used ListFragment and simple ArrayAdapter quite often. And now I want to try some more by customizing BaseAdapter. But something happened, the List is not showing at all. I don't have any error (the Logcat also saying there're no error). But I debug it, and found out that getView() in my customized BaseAdapter is not called. I wonder why?

Here's the snippet:

#favorite_list_layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">

<ListView
android:id="@+id/favorite_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

#favorite_list_item

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/favorite_text"
android:layout_margin="5dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="0dp"
android:textSize="35sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/favorite_text_details"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="5dp"
android:fontFamily="sans-serif-light"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</LinearLayout>

#FavoritesFragment

public class FavoritesFragment extends ListFragment {

[MENTION=439709]override[/MENTION]
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

//... setting variable favList, and this code is working. favList is not empty and there're no error

setListAdapter(new FavoriteAdapter(getActivity(), favList));
}
}

FavoriteAdapter, extends BaseAdapter

public class FavoriteAdapter extends BaseAdapter {

private Context ctx;
List<DMapData> list;

public FavoriteAdapter(Context context, List<DMapData> list) {
this.ctx = context;
this.list = list;
System.out.println("constructor executed!");
}

[MENTION=439709]override[/MENTION]
public int getCount() {
return list.size();
}

[MENTION=439709]override[/MENTION]
public Object getItem(int i) {
return list.get(i);
}

[MENTION=439709]override[/MENTION]
public long getItemId(int i) {
return i;
}

[MENTION=439709]override[/MENTION]
public View getView(int position, View convertView, ViewGroup parent) {
System.out.println("GetView is executed"); //But it's not.
View rowView = convertView;

if (rowView == null) {
LayoutInflater inflater = (LayoutInflater) ctx
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflater.inflate(R.layout.favorite_list_item, parent, false);
}

TextView favText = (TextView) rowView.findViewById(R.id.favorite_text);
TextView detailsText = (TextView) rowView.findViewById(R.id.favorite_text_details);

DMapData data = list.get(position);
System.out.println("DMapData from List");
favText.setText(data.getName());
detailsText.setText(data.getDetails().length()<=50? data.getDetails() : data.getDetails().substring(0, 51).concat("..."));

System.out.println("At the end of getView()");
return rowView;
}
}

Thanks :)