我正在尝试将以编程方式创建的布局添加到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());
但上面的代码不起作用。