无法使用 com.tns 找到 class
Can't use com.tns to find a class
我正在尝试使用 Nativescript 和 Angular 制作一个小部件。
我使用 this 示例来进一步帮助我,但现在我被困在这段代码上了。
我在互联网上找不到任何帮助,我自己也搞不清楚。
这是我的组件,与我使用的示例非常相似,因为我是 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
。
我正在尝试使用 Nativescript 和 Angular 制作一个小部件。
我使用 this 示例来进一步帮助我,但现在我被困在这段代码上了。
我在互联网上找不到任何帮助,我自己也搞不清楚。
这是我的组件,与我使用的示例非常相似,因为我是 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
。