Die Daten kommen aus einer Liste mit Objekten einer selbst erstellten Klasse (classRelease).
Also wäre es am günstigen in die neue Activity die Position und die Liste zu übergeben und dann dort den Eintrag rauszusuchen?
Also der Adapter sieht so aus:
public class pointsAdapter extends ArrayAdapter<classRelease> {
private Context context;
private List<classRelease> releases;
public pointsAdapter(Context context, List<classRelease> releases) {
super(context, R.layout.row_points, releases);
this.context = context;
this.releases = releases;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = inflater.inflate(R.layout.row_points, parent, false);
ImageView icon = (ImageView) row.findViewById(R.id.icon);
TextView release = (TextView) row.findViewById(R.id.release);
TextView titel = (TextView) row.findViewById(R.id.titel);
TextView result = (TextView) row.findViewById(R.id.result);
int resultInt = releases.get(position).getResult();
release.setText(releases.get(position).getRelease());
titel.setText(releases.get(position).getTitle());
String answers = releases.get(position).getCorrectAnswered();
if(resultInt == 0) {
icon.setImageResource(R.drawable.not);
result.setText("Nicht teilgenommen");
}else if(resultInt == 1){
icon.setImageResource(R.drawable.fail);
result.setText("Nicht bestanden: " + answers + "% richtig beantwortet");
}else if (resultInt == 2){
icon.setImageResource(R.drawable.passed);
result.setText("Bestanden: " + answers + "% richtig beantwortet");
}
return row;
}
}
Die Row sieht so aus:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="6dip">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6dip"
android:contentDescription="Symbol"
android:src="@drawable/not"
android:gravity="center_vertical"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<TextView
android:id="@+id/release"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Example application"
android:textSize="16sp"
android:ellipsize="end"
android:lines="1"
/>
<TextView
android:id="@+id/titel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Example application"
android:textSize="16sp"
android:ellipsize="end"
android:lines="1"
/>
<TextView
android:id="@+id/result"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Description"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.