GetView () override problem

I keep getting an error when overriding the getview method. This is what I have:

Public class UnwatchedEpisodesActivity extends ListActivity {

private String[] values = new String[]{"Row 1", "Row 2", "Row 3"};

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.episode_main);
    setListAdapter(new EpisodeListAdapter());

}

private class EpisodeListAdapter extends ArrayAdapter<String>{

    private LayoutInflater li = LayoutInflater.from(this.getContext());

    public EpisodeListAdapter(){
        super(UnwatchedEpisodesActivity.this, 0, values);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView == null){
            convertView = li.inflate(R.layout.episode_row, parent, false);
        }

        ((TextView) convertView.findViewById(R.id.text1)).setText(values[position]);
        return convertView;
    }

}

and my xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/ep_layout"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:id="@android:id/text1" />
</LinearLayout>

(I also tried without line out, it doesn't matter) I get this error.

Do you guys have any idea?

One more question: What if I want to separate values ​​in groups? I want the list to show something like:

-----------
first part
-----------
Row 1
Row 2
-----------
second part
-----------
Row 3

Obviously, this is just an example; basically i want to know how to add these "delimiters"

+3
source share
2 answers

Use android: id = "@android: id / text1"android:id="@+id/text1" instead for the first part.

2- , :

xml getView(). :

if (position == 0) {
    convertView = li.inflate(R.layout.episode_row, parent, false);
    //fetch the text view and other things and set their value
    return convertView;
} else if (position == 1) {
    //similarly do here also and return convertview
}

, .

+1

TextView id

android:id="@+id/text1"

: android:id="@android:id/text1" !

ExpandableListActivity, ListActivity, (, ..), values.

BaseExpandableListAdapter .

, , . , , .

getView BaseExpandableListAdapter getChildView, TextView getGroupView .

, .

+3

All Articles