0

When the statement convertView = mInflater.inflate(R.layout.listitem_course, null); execute in the following overridden method of BaseAdapter the app stops. I dont know why.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Log.i(StudyManagerDataSource.LOG_TAG,
            "CourseListAdapter -> getView called!");
    if (convertView == null) {
        Log.i(StudyManagerDataSource.LOG_TAG,
                "CourseListAdapter -> Convet view is null called 1!");
        convertView = mInflater.inflate(R.layout.listitem_course, null);

        mViewHolder = new ViewHolder();

        mViewHolder.courseNameTextView = (TextView) convertView
                .findViewById(R.id.courseNameTextView);

        convertView.setTag(mViewHolder);

    } else {
        mViewHolder = (ViewHolder) convertView.getTag();
    }

    Course mCourse = mCourses.get(position);

    mViewHolder.courseNameTextView.setText(mCourse.getCourseName());

    Log.i(StudyManagerDataSource.LOG_TAG,
            "CourseListAdapter -> getView executed!");

    return convertView;
}

The code for listitem_course is as follows:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<TextView
    android:id="@+id/courseNameTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="20sp" />
</LinearLayout>
A--C
  • 36,351
  • 10
  • 106
  • 92
Shajeel Afzal
  • 5,913
  • 6
  • 43
  • 70

1 Answers1

0

You should use this to inflate your item:

mInflater.inflate(R.layout.listitem_course, parent, false);

EDIT:

The parent is the ViewGroup in which your inflated view will be inserted, in your case, the parent argument from the getView() method..

Cata
  • 11,133
  • 11
  • 65
  • 86
  • How strange is it? The last night it was not working and today it is working. How bad the Eclipse IDE is :( Problem Solved Thanks for all. – Shajeel Afzal Feb 19 '13 at 07:53