android - 无法使用 com.tns 查找课程
问题描述
我正在尝试使用 Nativescript 和 Angular 制作一个小部件。
我用这个例子来进一步帮助我,但现在我被困在这段代码上。
我在互联网上找不到任何帮助,我自己也无法弄清楚。
这是我的组件,与我使用的示例非常相似,因为我是 Nativescript 的新手。
@JavaProxy("a.b.MyWidget")
export class WidgetComponent extends android.appwidget.AppWidgetProvider {
onUpdate(context, appWidgetManager, appWidgetIds): void {
var appWidgetsLen = appWidgetIds.length
for (let i = 0; i < appWidgetsLen; i++) {
this.updateWidget(context, appWidgetManager, appWidgetIds, appWidgetIds[i]);
}
}
updateWidget(ontext, appWidgetManager, appWidgetIds, widgetId){
const context = app.android.context;
let views:any = context.getResources().getIdentifier("appwidget", "layout", context.getPackageName());
let resourceId:any = context.getResources().getIdentifier("appwidget", "id", context.getPackageName())
var textView = new android.widget.RemoteViews(context.getPackageName(), views);
textView.setTextViewText(resourceId.taps_text, "Just for testing");
var intent: android.content.Intent = new android.content.Intent(context, com.tns.MyWidget);
intent.setAction(android.appwidget.AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent.putExtra(android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
var startAppIntent = new android.content.Intent(context, com.tns.NativeScriptActivity.class); // the activity defined in AndroidManifest
startAppIntent.putExtra(android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
appWidgetManager.updateAppWidget(widgetId, textView);
}
}
在布局文件中没有文本属性,我想从组件中设置它。
com.tns.MyWidget
当我调用意图时,它会卡在零件上。
解决方案
您已将 JavaProxy 声明为a.b.MyWidget
,因此您必须访问它而不是com.tns.MyWidget
示例。
推荐阅读
- python - 如何匹配深度自动编码器的编码器解码器尺寸?
- javascript - 我怎样才能用玩笑正确地测试我的解析器?
- node.js - 在具有外部时间限制的 Node/Express 中链接异步等待调用
- r - 如果在另一列中满足条件,则更改日期列
- android - 如何从 Firebase 数据库中检索数据 [ANDROID STUDIO]
- tsql - SQL - Rank 或 Row_Number 未带回所需数据
- sql - 如何根据postgres中其他列的值插入单行的文本列
- python - 如何将字符串值设置为 django 模型中浮点字段的默认值
- javascript - 如何使用 PUG 文件显示 MySQL 数据
- r - 从 Microsoft Azure 平台访问 R 输出