Problem mit eigenen ListViewAdapter

S

Scogit

Ambitioniertes Mitglied
2
Servus,
ich hab ein Problem mit einen Adapter.
Das TextView Objekt title ist immer null.

Hat hier jemand eine Idee warum das Object nicht gefunden wird?



Code:
public class ProgramAdapter extends BaseAdapter {

    private Context mContext;
    private int mRowResID;
    private Vector<EpgChannel> mProgramList;

    public ProgramAdapter(Context context, int rowResID,
            Vector<EpgChannel> programList) {
        mContext = context;
        mRowResID = rowResID;
        mProgramList = programList;
    }

    public int getCount() {
        return mProgramList.size();
    }

    public Object getItem(int position) {
        return mProgramList.get(position);
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        EpgChannel EpgChannel = mProgramList.get(position);
        LayoutInflater inflate = LayoutInflater.from( mContext );
        View v = inflate.inflate(mRowResID, parent, false);

        EpgEvent event = EpgChannel.iterator().next();

        TextView title = (TextView) v.findViewById(R.id.title);

        title.setText(event.getTitle());

        return v;
    }

}
Code:
public class CurrentActivity extends MainMenuActivity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.current);

        JRegistry registry = JRegistry.getInstance();

        if  (registry.isRegistered("CommandWrapper")) {
            CommandWrapper cmdWrapper = (CommandWrapper) registry.locate("CommandWrapper");
            Vector<EpgChannel> result = cmdWrapper.getProgram(CommandWrapper.PROGRAM_CURRENT);

            ProgramAdapter programAdapter = new ProgramAdapter(
                                            this,
                                            R.layout.program_row,
                                            result);

            ListView myList = (ListView)findViewById(R.id.mylist);

            myList.setAdapter(programAdapter);
        }

    }
}
Code:
<?xml version="1.0" encoding="utf-8"?>

<TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content" android:layout_height="wrap_content"><TextView android:text="TextView01" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView><TextView android:text="TextView02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/title"></TextView>
</TableRow>

</TableLayout>
 
Zuletzt bearbeitet:
Ich weis nicht wirklich was ich jetzt anders gemacht habe da kein Unterschied zu sehen ist aber nachdem ich einmal Project -> clean aufgerufen habe scheint es zu funktionieren.
 

Ähnliche Themen

FabianDev
Antworten
5
Aufrufe
549
swa00
swa00
R
Antworten
3
Aufrufe
1.614
Ritartet
R
R
  • RudolfHagen
Antworten
1
Aufrufe
649
koje71
koje71
Zurück
Oben Unten