【发布时间】:2015-05-15 06:39:17
【问题描述】:
我刚刚开始涉足 Android 开发。现在,我在 Android Studio 中有一个程序,它有两列图像,每列大约 6 张图像。我想这样做,所以如果我单击该图像,它将出现在新活动中。现在,我只是在加载这样的布局:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String name = intent.getStringExtra(Main.CHAMPION_NAME);
setContentView(R.layout.activity_champion_page);
}
setContentView 中的布局如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="atree496.leaguestats.ChampionPage">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/azir"
android:id="@+id/imageView" />
</LinearLayout>
到目前为止,它只打开一张图片,因为它是这样设置的,但我希望能够让图片成为我点击的那一张。为了实现这一目标,我需要做哪些改变?再说一次,我对此很陌生。感谢您提供的任何帮助。
【问题讨论】:
标签: java android android-layout android-activity android-studio