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?
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: