我一直在寻找一个具体的例子,无法在任何地方找到它.
我想要做的是:从我的应用程序单击一个按钮,然后转到我的应用程序动态壁纸的动态壁纸预览,以便用户可以选择激活它.
现在我在网上看到的,我将使用WallpaperManager的 ACTION_CHANGE_LIVE_WALLPAPER和指向我的LiveWallpapers ComponentName的EXTRA_LIVE_WALLPAPER_COMPONENT.
这是我到目前为止的代码.谁知道我做错了什么?截至目前,我点击按钮,没有任何反应...(我记录了它,它实际上达到了这个代码).
Intent i = new Intent();
i.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
i.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, "com.example.myapp.livewallpaper.LiveWallpaperService");
startActivity(i);
Run Code Online (Sandbox Code Playgroud)
如果您需要我忘记发布的更多信息,请告诉我.
*我也知道这是API 16+,这只是我的情况,当手机是API 16+
XML
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton1"
android:src="@drawable/image1"
android:onClick="buttonClick"
/>
JAVA
--------------------
public void buttonClick(View v)
{
Button aButton = (Button)v;
aButton.setBackgroundResource(R.drawable.image2);
}
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止没有运气的尝试......
我希望能够单击按钮并将图像更改为image2,还有其他图像我会根据其他变量将其更改为.我真的卡住了..我会继续看其他问题,如果我找到答案,我会在这里发布.