本文整理了Java中android.appwidget.AppWidgetHost.createView()
方法的一些代码示例,展示了AppWidgetHost.createView()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AppWidgetHost.createView()
方法的具体详情如下:
包路径:android.appwidget.AppWidgetHost
类名称:AppWidgetHost
方法名:createView
暂无
代码示例来源:origin: robolectric/robolectric
@Test
public void createView_shouldReturnAppWidgetHostView() throws Exception {
AppWidgetHostView hostView = appWidgetHost.createView(context, 0, null);
assertNotNull(hostView);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void createView_shouldSetViewsAppWidgetId() throws Exception {
AppWidgetHostView hostView = appWidgetHost.createView(context, 765, null);
assertThat(hostView.getAppWidgetId()).isEqualTo(765);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void createView_shouldSetViewsContext() throws Exception {
AppWidgetHostView hostView = appWidgetHost.createView(context, 0, null);
assertThat(hostView.getContext()).isSameAs(context);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void createView_shouldSetHostViewsHost() throws Exception {
AppWidgetHostView hostView = appWidgetHost.createView(context, 0, null);
assertThat(shadowOf(hostView).getHost()).isSameAs(appWidgetHost);
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void createView_shouldSetViewsAppWidgetInfo() throws Exception {
AppWidgetProviderInfo info = new AppWidgetProviderInfo();
AppWidgetHostView hostView = appWidgetHost.createView(context, 0, info);
assertThat(hostView.getAppWidgetInfo()).isSameAs(info);
}
代码示例来源:origin: Neamar/KISS
/**
* Adds a widget to the widget area on the MainActivity
*
* @param appWidgetId id of widget to add
*/
private void addWidgetToLauncher(int appWidgetId) {
// only add widgets if in minimal mode (may need launcher restart when turned on)
if (prefs.getBoolean("history-hide", true)) {
// remove empty list view when using widgets, this would block touches on the widget
mainActivity.emptyListView.setVisibility(View.GONE);
//add widget to view
AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
if (appWidgetInfo == null) {
removeAllWidgets();
return;
}
AppWidgetHostView hostView = mAppWidgetHost.createView(mainActivity, appWidgetId, appWidgetInfo);
hostView.setMinimumHeight(appWidgetInfo.minHeight);
hostView.setAppWidget(appWidgetId, appWidgetInfo);
if (Build.VERSION.SDK_INT > 15) {
hostView.updateAppWidgetSize(null, appWidgetInfo.minWidth, appWidgetInfo.minHeight, appWidgetInfo.minWidth, appWidgetInfo.minHeight);
}
widgetArea.addView(hostView);
}
// only one widget allowed so widgetUsed is true now, even if not added to view
widgetUsed = true;
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
public AppWidgetHostView createView(Context context, int appWidgetId,
LauncherAppWidgetProviderInfo appWidget) {
if (appWidget.isCustomWidget) {
LauncherAppWidgetHostView lahv = new LauncherAppWidgetHostView(context);
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(appWidget.initialLayout, lahv);
lahv.setAppWidget(0, appWidget);
lahv.updateLastInflationOrientation();
return lahv;
} else {
return super.createView(context, appWidgetId, appWidget);
}
}
代码示例来源:origin: fookwood/Launcher3
public AppWidgetHostView createView(Context context, int appWidgetId,
LauncherAppWidgetProviderInfo appWidget) {
if (appWidget.isCustomWidget) {
LauncherAppWidgetHostView lahv = new LauncherAppWidgetHostView(context);
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(appWidget.initialLayout, lahv);
lahv.setAppWidget(0, appWidget);
lahv.updateLastInflationOrientation();
return lahv;
} else {
return super.createView(context, appWidgetId, appWidget);
}
}
代码示例来源:origin: klinker24/launcher3
public AppWidgetHostView createView(Context context, int appWidgetId,
LauncherAppWidgetProviderInfo appWidget) {
if (appWidget.isCustomWidget) {
LauncherAppWidgetHostView lahv = new LauncherAppWidgetHostView(context);
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(appWidget.initialLayout, lahv);
lahv.setAppWidget(0, appWidget);
lahv.updateLastInflationOrientation();
return lahv;
} else {
return super.createView(context, appWidgetId, appWidget);
}
}
代码示例来源:origin: enricocid/LaunchEnr
public AppWidgetHostView createView(Context context, int appWidgetId,
LauncherAppWidgetProviderInfo appWidget) {
if (appWidget.isCustomWidget) {
LauncherAppWidgetHostView lahv = new LauncherAppWidgetHostView(context);
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(appWidget.initialLayout, lahv);
lahv.setAppWidget(0, appWidget);
lahv.updateLastInflationOrientation();
return lahv;
} else {
try {
return super.createView(context, appWidgetId, appWidget);
} catch (Exception e) {
if (!Utilities.isBinderSizeError(e)) {
throw new RuntimeException(e);
}
// If the exception was thrown while fetching the remote views, let the view stay.
// This will ensure that if the widget posts a valid update later, the view
// will update.
LauncherAppWidgetHostView view = mViews.get(appWidgetId);
if (view == null) {
view = onCreateView(mLauncher, appWidgetId, appWidget);
}
view.setAppWidget(appWidgetId, appWidget);
view.switchToErrorView();
return view;
}
}
}
代码示例来源:origin: MoMoWait/LeanbackLauncher
this.mAppWidgetHostView = this.mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
this.mAppWidgetHostView.setAppWidget(appWidgetId, appWidgetInfo);
wrapper.addView(this.mAppWidgetHostView);
代码示例来源:origin: rockon999/LeanbackLauncher
this.mAppWidgetHostView = this.mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
this.mAppWidgetHostView.setAppWidget(appWidgetId, appWidgetInfo);
wrapper.addView(this.mAppWidgetHostView);
代码示例来源:origin: clemensbartz/essential-launcher
/**
* Add a host view to the frame layout for a widget id.
* @param appWidgetId the widget id
*/
public void addHostView(final int appWidgetId) {
frWidget.removeAllViews();
if (hasAppWidgets(this)) {
final AppWidgetProviderInfo appWidgetInfo = appWidgetManager.getAppWidgetInfo(appWidgetId);
if (appWidgetInfo != null) {
final AppWidgetHostView hostView = appWidgetHost.createView(this, appWidgetId, appWidgetInfo);
hostView.setAppWidget(appWidgetId, appWidgetInfo);
frWidget.addView(hostView);
frWidget.requestLayout();
final Bundle options = BundleUtil.getWidgetOptionsBundle(frWidget.getMeasuredWidth(), frWidget.getMeasuredHeight(), frWidget.getMeasuredWidth(), frWidget.getMeasuredHeight());
hostView.updateAppWidgetOptions(options);
} else {
model.setAppWidgetId(-1);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!