我有一个按钮,是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() –