将参数传递给自定义Android小部件

时间:2013-08-13 11:14:09

标签: java android widget

是否可以将参数传递给自定义小部件?我基本上要求在某些情况下显示不同的文本,并且真的不想只复制和粘贴整个代码。以下是我目前为payment_example.xml所做的事情:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/receipt_layout">

   <TextView
       android:id="@+id/payment_label"
       android:text="@string/payment_label"
   />
</RelativeLayout>

所以我需要在TextView - android:text字段中显示不同的文本。从Java端,它调用这个小部件如下:

RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.layout);
final View printLayout = inflater.inflate(R.layout.payment_example, mainLayout, false);

所以我的问题是,是否有可能影响此小部件中显示的文本?

0 个答案:

没有答案
相关问题