Aka*_*eet 3 user-interface android android-linearlayout
考虑我正在为我的应用程序使用线性布局
<TextView
android:text="product 1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textColor="@android:color/white"
android:textSize="54sp"
android:background="#009611" />
<TextView
android:text="product 2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textColor="@android:color/white"
android:textSize="54sp"
android:background="#123431" />
<TextView
android:text="product 3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textColor="@android:color/white"
android:textSize="54sp"
android:background="#009688" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的输出是:
当我选择product1它应该打开product1_des Activity
当我选择product2它应该打开product2_des Activity
当我选择product3它应该打开product3_des Activity
然后继续..
我有 1000 个产品,我应该创建 1000 个活动吗?我如何使用product_des活动(即单个活动)来支持我所有的 1000 种产品,这些产品具有与该产品相关的不同描述?请帮我。
我有 1000 个产品,我应该创建 1000 个活动吗?我如何使用 product_des 活动(即单个活动)来支持我所有的 1000 种产品,这些产品具有与该产品相关的不同描述?请帮我。
不!!!
例如,您可以创建一个Activity调用,ProductDetail但只有一个,然后在任何地方您想显示您可以使用的产品详细信息putExtras()
Intent intent = new Intent(this, ProductDetail.class);
intent.putExtra("productName", ProductName);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
在ProductDetail你可以得到产品的名称Bundle
Bundle b = new Bundle();
b = getIntent().getExtras();
String name = b.getString("productName");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1017 次 |
| 最近记录: |