| |||||||
Das Thema "Problem mit eigenen ListViewAdapter" befindet sich unter Android App Entwicklung auf Android-Hilfe.de.
|
| | Themen-Optionen | Ansicht |
| | #1 (permalink) |
| Android-Hilfe.de Mitglied Modell: Samsung Galaxy Registriert seit: 16.08.2009
Beiträge: 69
Abgegebene Danke: 1
Erhielt 2 Danke für 2 Beiträge
| 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> Geändert von Scogit (23.08.2009 um 15:49 Uhr) |
| | |
| | #2 (permalink) |
| Android-Hilfe.de Mitglied Modell: Samsung Galaxy Registriert seit: 16.08.2009
Beiträge: 69
Abgegebene Danke: 1
Erhielt 2 Danke für 2 Beiträge
|
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.
|
| | |
![]() |
|
| Themen-Optionen | |
| Ansicht | |
| |
| ||||
| Thema | Autor | Forum | Antworten | Letzter Beitrag |
| Klingeltöne & Benachrichtigungen / Eure eigenen Töne & Tippsammlung | Autarkis | Android Themes | 27 | 17.03.2010 09:13 |
| Probleme beim flashen eines eigenen Boot-Bildchens (custom boot image) | opallabtb | Android Themes | 6 | 16.08.2009 15:27 |
| eigenen googleaccount einrichten | Antraxxxa | T-Mobile G1 Forum | 12 | 11.05.2009 21:50 |