【问题标题】:App with menu - how to? [closed]带菜单的应用程序 - 如何? [关闭]
【发布时间】:2018-03-19 17:13:59
【问题描述】:

我需要你的帮助。我需要制作一个应用程序作为学校项目。我做了一个启动画面,然后在我想制作菜单的 activity_main.xml 上。所以我写了代码,其中一部分是:

<android.support.v7.widget.CardView
            android:foreground="?android:attr/selectableItemBackground"
            android:clickable="true"
            android:layout_width="160dp"
            android:layout_height="190dp"
            android:layout_margin="10dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:gravity="center">
                <ImageView
                    android:layout_width="64dp"
                    android:layout_height="64dp"
                    android:background="@drawable/circlebackgroundpurple"
                    android:src="@drawable/ic_account_balance_black_24dp"
                    android:padding="10dp"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:layout_marginTop="10dp"
                    android:text="Admitere"
                    android:textAlignment="center"/>
                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="@color/lightgray"
                    android:layout_margin="10dp"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:text="Conditii admitere specializarea IE"
                    android:padding="5dp"
                    android:textColor="@android:color/darker_gray"/>

            </LinearLayout>

现在我必须让它工作,当我点击图像时,它会打开一个新页面。但我不知道如何建立这种联系。你能帮帮我吗?

【问题讨论】:

  • 你的意思是你想在一帧内打开所有页面?

标签: android menu connection


【解决方案1】:

为 ImageView 提供一个 id 并在您的 java 代码中将其设置为 onClicklistner。使用意图转到另一个活动

【讨论】:

  • 所以基本上我需要为每个活动创建一个不同的类?因为当它打开一个新页面时,我想在那里放一些信息
  • 是的。每个活动都有对应的java代码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-22
  • 1970-01-01
相关资源
最近更新 更多