【问题标题】:Android adding dynamically View in RemoteViews show only the first view! How I can change layout_alignParentBottom from code?Android 在 RemoteViews 中动态添加 View 只显示第一个视图!如何从代码中更改 layout_alignParentBottom?
【发布时间】:2012-07-20 15:23:36
【问题描述】:

如何使用像for 这样的循环在相对布局中动态添加视图?

这是我的代码:

RemoteViews remoteViews = new RemoteViews(c.getPackageName(), R.layout.layout_1);

    for(int i=0; i<10; i++){
            RemoteViews newView = new RemoteViews(c.getPackageName(), R.layout.element);
            newView.setImageViewResource(R.id.notif_toggle, R.drawable.bt_close_n);
            remoteViews.addView(R.id.layout_1, newView);

    }
            int statusIcon = R.drawable.ic_launcher;
            notification = new Notification(statusIcon, c.getResources().getString(R.string.app_name), System
                    .currentTimeMillis());
            notification.flags = notification.flags | Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;

            notification.contentView = remoteViews;

            nm.notify(3,notification);

我知道“正在添加的视图的子级具有属性 layout_alignParentBottom="true",这导致它填充整个父级,阻止任何其他子级。删除该属性允许其他子级出现”。

那么我该如何设置 layout_alignParentBottom="false"?? 非常感谢...

【问题讨论】:

  • 你想在这里做什么

标签: android layout view alignment remoteview


【解决方案1】:

不确定您要在这里做什么,但也许您正在寻找 ListView。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-22
    • 2016-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-03
    相关资源
    最近更新 更多