我有一個按鈕,是tablerow的內部的最後一個元素,例如:發送從一個視圖數據到另一個視圖與按鈕
<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>
該按鈕的代碼看起來是這樣的:
public void ShowView(View view) {
Intent intent = new Intent(this, DisplaySeekAgain.class);
startActivity(intent);
}
當按下按鈕,我需要從這個佈局發送數據,以新的佈局,特別是這樣的數據:
的android:文本=「@字符串/ person1_na我」
從TextViews
這一個:
機器人:SRC = 「@繪製/ profile_one」
從ImageView的。
我試圖在按鈕的代碼使用標籤像這樣的名字:
String text_tag = view.getTag().toString();
intent.putExtra(EXTRA_NAME, text_tag);
這工作,但我無法弄清楚如何還從ImageView的發送圖像。
有沒有辦法同時發送?
謝謝!
如何在圖像視圖中傳遞myImageView?謝謝 – SkyeBoniwell
@SkyeBoniwell imageView應該是一個全局變量,你應該在'setContentView()''myImageView =(ImageView)findViewById(R.id.person1_icon)'之後的onCreate() –