• <legend id='LhoVd'><style id='LhoVd'><dir id='LhoVd'><q id='LhoVd'></q></dir></style></legend>

    <tfoot id='LhoVd'></tfoot>
    <i id='LhoVd'><tr id='LhoVd'><dt id='LhoVd'><q id='LhoVd'><span id='LhoVd'><b id='LhoVd'><form id='LhoVd'><ins id='LhoVd'></ins><ul id='LhoVd'></ul><sub id='LhoVd'></sub></form><legend id='LhoVd'></legend><bdo id='LhoVd'><pre id='LhoVd'><center id='LhoVd'></center></pre></bdo></b><th id='LhoVd'></th></span></q></dt></tr></i><div id='LhoVd'><tfoot id='LhoVd'></tfoot><dl id='LhoVd'><fieldset id='LhoVd'></fieldset></dl></div>

      <small id='LhoVd'></small><noframes id='LhoVd'>

          <bdo id='LhoVd'></bdo><ul id='LhoVd'></ul>

        以编程方式将 TextViews 添加到主屏幕小部件

        时间:2023-09-08

            <bdo id='ncWaJ'></bdo><ul id='ncWaJ'></ul>

            <small id='ncWaJ'></small><noframes id='ncWaJ'>

              <i id='ncWaJ'><tr id='ncWaJ'><dt id='ncWaJ'><q id='ncWaJ'><span id='ncWaJ'><b id='ncWaJ'><form id='ncWaJ'><ins id='ncWaJ'></ins><ul id='ncWaJ'></ul><sub id='ncWaJ'></sub></form><legend id='ncWaJ'></legend><bdo id='ncWaJ'><pre id='ncWaJ'><center id='ncWaJ'></center></pre></bdo></b><th id='ncWaJ'></th></span></q></dt></tr></i><div id='ncWaJ'><tfoot id='ncWaJ'></tfoot><dl id='ncWaJ'><fieldset id='ncWaJ'></fieldset></dl></div>
                <tbody id='ncWaJ'></tbody>

                  <tfoot id='ncWaJ'></tfoot>
                  <legend id='ncWaJ'><style id='ncWaJ'><dir id='ncWaJ'><q id='ncWaJ'></q></dir></style></legend>

                  本文介绍了以编程方式将 TextViews 添加到主屏幕小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想以编程方式将文本视图控件添加到我的主屏幕小部件.在下面的示例中,我使用 TextViews 填充 Linearlayout,但我应该如何在此处使用 RemoteViews?它只接受xml资源布局作为参数.

                  I want to programmatically add Text Views controls to my home screen widget. In the following example I populate Linearlayout with TextViews, but how should I use RemoteViews here? It only accepts xml resource layout as a parameter.

                  public class MyWidget extends AppWidgetProvider {
                      public void onUpdate(Context _context, AppWidgetManager appWidgetManager, 
                                           int[] appWidgetIds) {
                  
                          LinearLayout l = new LinearLayout(_context);
                  
                          for (int i = 0; i < 10; i++) {
                              TextView t = new TextView(_context);
                              t.setText("Hello");
                              l.addView(t); 
                          }
                      }
                  }
                  

                  我看到的所有教程都使用其预定义控件的值明确填充 RemoteViews 对象.我想以编程方式添加控件.

                  All tutorials I saw explicitly populate RemoteViews object with values for its predefined controls. And I want to add controls programmaticaly.

                  RemoteViews views = new RemoteViews(context.getPackageName(),
                  R.layout.my_widget);
                  views.setTextViewText(R.id.widget_control1, value1);
                  views.setTextViewText(R.id.widget_control2, value2);
                  

                  推荐答案

                  好的,appwidgets 是不可能的.只接受 xml 资源.

                  Ok, It is impossible for appwidgets. Only xml resources are accepted.

                  这篇关于以编程方式将 TextViews 添加到主屏幕小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何更改 android 小部件选择对话框中显示的图像? 下一篇:编译器错误:“初始化器元素不是编译时常量";

                  相关文章

                  • <bdo id='QEI9r'></bdo><ul id='QEI9r'></ul>
                    <legend id='QEI9r'><style id='QEI9r'><dir id='QEI9r'><q id='QEI9r'></q></dir></style></legend>

                    <i id='QEI9r'><tr id='QEI9r'><dt id='QEI9r'><q id='QEI9r'><span id='QEI9r'><b id='QEI9r'><form id='QEI9r'><ins id='QEI9r'></ins><ul id='QEI9r'></ul><sub id='QEI9r'></sub></form><legend id='QEI9r'></legend><bdo id='QEI9r'><pre id='QEI9r'><center id='QEI9r'></center></pre></bdo></b><th id='QEI9r'></th></span></q></dt></tr></i><div id='QEI9r'><tfoot id='QEI9r'></tfoot><dl id='QEI9r'><fieldset id='QEI9r'></fieldset></dl></div>
                    <tfoot id='QEI9r'></tfoot>
                    1. <small id='QEI9r'></small><noframes id='QEI9r'>