如何以编程方式创建布局到Remoteview?

时间:2015-07-27 08:36:29

标签: android push-notification android-remoteview

我正在尝试将以编程方式创建的布局添加到remoteview

这是我的小型演示,但它没有工作:

LinearLayout parent = new LinearLayout(getAppContext());
parent.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
parent.setOrientation(LinearLayout.HORIZONTAL);

TextView tv1 = new TextView(getAppContext());
parent.addView(tv1);

parent.setId(0x7f03021b);

Remoteviews contentView = new RemoteViews(getAppContext().getPackageName(), parent.getId());

但上面的代码不起作用。

0 个答案:

没有答案