Ich habe einen Knopf, der das letzte Element in einem TableRow ist, wie folgt aus:Senden von Daten von einer Ansicht zu einer anderen Ansicht mit einem Knopf
<TableRow
android:id="@+id/tableRow1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
<ImageView
android:id="@+id/person1_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="4dp"
android:tag="@drawable/profile_one"
android:src="@drawable/profile_one"
/>
<TableLayout
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_marginLeft="4dp"
android:orientation="horizontal">
<TableRow android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp">
<TextView android:id="@+id/person1_seek"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/person1_name"
android:hint="@string/person1_name" />
</TableRow>
</TableLayout>
<Button
android:id="@+id/addButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="ShowView" />
</TableRow>
Der Code für die Schaltfläche wie folgt aussieht:
public void ShowView(View view) {
Intent intent = new Intent(this, DisplaySeekAgain.class);
startActivity(intent);
}
Wenn die Taste gedrückt wird, muss ich Daten aus diesem Layout senden, an das neue Layout, speziell diese Daten:
android: text = "@ Zeichenfolge/person1_na me“
aus einem der Textviews
und dieses:
android: src = "@ ziehbar/profile_one"
vom Image.
Ich habe versucht, einen Tag in der Button-Code für den Namen wie folgt aus:
String text_tag = view.getTag().toString();
intent.putExtra(EXTRA_NAME, text_tag);
Und das funktioniert, aber ich kann nicht herausfinden, wie auch aus dem Image das Bild zu senden.
Gibt es eine Möglichkeit, beides zu senden?
Danke!
Wie gebe ich die Bildansicht weiter, in Ihrem Beispiel myImageView? Danke – SkyeBoniwell
@SkyeBoniwell Die ImageView sollte eine globale Variable sein und Sie sollten es auf der onCreate() nach 'setContentView()' 'myImageView = (ImageView) findViewById (R.id.person1_icon);' –