相关疑难解决方法(0)

如何传递数据并从Widget中打开一个Activity?[Android]产品

在我ListProvider实现的类中,RemoteViewsFactory我已经在下面编写了以下代码:

@Override
public RemoteViews getViewAt(int position) {
    RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.list_row);

rv.setTextViewText(R.id.heading, merch_name);
        rv.setTextViewText(R.id.content, teaser);

        Bundle extras = new Bundle();
        extras.putInt(WidgetProvider.EXTRA_ITEM, position);
        extras.putString(WidgetProvider.MERCHANT_ITEM, mWidgetItems.get(position).merchant_id);


        Intent fillInIntent = new Intent();
        fillInIntent.putExtras(extras);
        rv.setOnClickFillInIntent(R.id.llRow, fillInIntent);

  return rv;
}
Run Code Online (Sandbox Code Playgroud)

当我点击时,我把Logs in my onReceiveof WidgetProviderit中有正确的ID,但是在打开活动后它没有正确的ID放在哪里extras.还有时间,它没有打开Activity我提供的,只是打开我的MainActivity.当我从中删除我的应用程序recently open app然后使用时,会发生这种情况widget.

这里是我的代码onReceive在我WidgetProvider

 public class WidgetProvider extends AppWidgetProvider {

 public static final String TOAST_ACTION = "my.packagename.TOAST_ACTION";
public static final …
Run Code Online (Sandbox Code Playgroud)

android listview widget

9
推荐指数
1
解决办法
1281
查看次数

标签 统计

android ×1

listview ×1

widget ×1