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

    1. <tfoot id='SbHd9'></tfoot>
      • <bdo id='SbHd9'></bdo><ul id='SbHd9'></ul>
      <legend id='SbHd9'><style id='SbHd9'><dir id='SbHd9'><q id='SbHd9'></q></dir></style></legend>

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

      1. 按下小部件ListView项目时Android开始活动

        Android start activity when pressing widget ListView item(按下小部件ListView项目时Android开始活动)
          <i id='qSTpD'><tr id='qSTpD'><dt id='qSTpD'><q id='qSTpD'><span id='qSTpD'><b id='qSTpD'><form id='qSTpD'><ins id='qSTpD'></ins><ul id='qSTpD'></ul><sub id='qSTpD'></sub></form><legend id='qSTpD'></legend><bdo id='qSTpD'><pre id='qSTpD'><center id='qSTpD'></center></pre></bdo></b><th id='qSTpD'></th></span></q></dt></tr></i><div id='qSTpD'><tfoot id='qSTpD'></tfoot><dl id='qSTpD'><fieldset id='qSTpD'></fieldset></dl></div>

          • <tfoot id='qSTpD'></tfoot>
              <tbody id='qSTpD'></tbody>
          • <small id='qSTpD'></small><noframes id='qSTpD'>

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

                  <legend id='qSTpD'><style id='qSTpD'><dir id='qSTpD'><q id='qSTpD'></q></dir></style></legend>
                1. 本文介绍了按下小部件ListView项目时Android开始活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在开发一个 ListView 小部件,我希望用户能够在单击 ListView 时启动一个活动.我还没有找到任何关于这方面的教程,所以我想知道是否有人可以指出我正确的方向或者分享一些代码.无论单击哪个 ListItem,我都想启动相同的活动,所以这不是问题.

                  I'm working on a ListView widget where I want the user to be able to launch a activity when the ListView is clicked. I haven't been able to find any sort of tutorial on this so I'm wondering if anyone could point me in the right direction or perhaps share some code. I want to launch the same activity regardless of which ListItem is clicked so that's not a problem.

                  感谢所有帮助!

                  推荐答案

                  看看这里并滚动到子标题向单个项目添加行为.

                  您需要确保从您的 AppWidgetProvider setOnClickFillInIntent() 都调用 setPendingIntentTemplate()你的 RemoteViewsService.RemoteViewsFactory 实现.

                  You need to make sure you call both setPendingIntentTemplate() from your AppWidgetProvider and setOnClickFillInIntent() from your RemoteViewsService.RemoteViewsFactory implementation.

                  例如:

                  public class Widget extends AppWidgetProvider {
                  
                      // ...
                  
                      public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
                  
                          for(int i = 0; i < appWidgetIds.length; i++){
                  
                              RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.widget);
                  
                              Intent startActivityIntent = new Intent(context, myActivity.class);
                              PendingIntent startActivityPendingIntent = PendingIntent.getActivity(context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
                              widget.setPendingIntentTemplate(R.id.list_view, startActivityPendingIntent);
                  
                              appWidgetManager.updateAppWidget(appWidgetIds[i], widget);
                  
                              // ...
                      }
                  }
                  
                  public class WidgetAdapter implements RemoteViewsService.RemoteViewsFactory {
                  
                      // ...
                  
                      @Override
                      public RemoteViews getViewAt(int position) {
                  
                      RemoteViews widgetRow = new RemoteViews(context.getPackageName(), R.layout.widget_row);
                  
                          Intent fillInIntent = new Intent();
                          fillInIntent.putExtra(Widget.EXTRA_LIST_VIEW_ROW_NUMBER, position);
                          widgetRow.setOnClickFillInIntent(R.id.list_view_row, fillInIntent);
                  
                          // ...
                  
                          return widgetRow;
                      }
                  }
                  

                  SDK 示例中的 StackWidget 示例中有一个更具说服力的示例,虽然我发现它有点难以找到(请参阅此处了解相关说明).它创建了一个显示 Toast 消息的意图,但它使用相同的代码.

                  There is a more conclusive example in the StackWidget sample which is in the SDK samples, although I found it somewhat difficult to find (see here for directions). It creates an intent to show a Toast message, but it uses the same code.

                  这篇关于按下小部件ListView项目时Android开始活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
                  cocos2d-android: how to display score(cocos2d-android:如何显示分数)
                  Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
                  SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
                  Android file copy(安卓文件拷贝)
                  Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)

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

                      <bdo id='MS32T'></bdo><ul id='MS32T'></ul>
                        <tbody id='MS32T'></tbody>
                      <legend id='MS32T'><style id='MS32T'><dir id='MS32T'><q id='MS32T'></q></dir></style></legend>

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