我正在尝试使用androids材料设计的调色板功能,但我在应用它时遇到了一些麻烦.
我已经成功生成了调色板,现在我试图将调色板传递给应用它的函数.
我遇到的问题是,当我将调色板传递给applyPalette函数时,没有任何方法palette.getDarkMutedColor().getRgb() , palette.getVibrantColor().getRgb()会使用调色板中的值填充.
我正在关注的教程没有提及其他任何其他内容,然后将调色板传递给函数,并且这样做将填充方法
这是生成器功能和应用功能,任何人都可以看到为什么这不起作用?
码
private void colorize(Bitmap photo) {
Palette palette = new Palette.Builder(photo).generate();
applyPalette(palette);
}
private void applyPalette(Palette palette) {
getWindow().setBackgroundDrawable(new ColorDrawable(palette.getDarkMutedColor().getRgb()));
TextView titleView = (TextView) findViewById(R.id.title);
titleView.setTextColor(palette.getVibrantColor().getRgb());
TextView descriptionView = (TextView) findViewById(R.id.description);
descriptionView.setTextColor(palette.getLightVibrantColor().getRgb());
colorRipple(R.id.info, palette.getDarkMutedColor().getRgb(),
palette.getDarkVibrantColor().getRgb());
colorRipple(R.id.star, palette.getMutedColor().getRgb(),
palette.getVibrantColor().getRgb());
View infoView = findViewById(R.id.information_container);
infoView.setBackgroundColor(palette.getLightMutedColor().getRgb());
AnimatedPathView star = (AnimatedPathView) findViewById(R.id.star_container);
star.setFillColor(palette.getVibrantColor().getRgb());
star.setStrokeColor(palette.getLightVibrantColor().getRgb());
}
Run Code Online (Sandbox Code Playgroud) 我创建了一个创建128位UUID字符串的方法,我现在想检查这是否是素数.我不能将字符串放入int中,因为它太大了.任何人都可以建议我如何检查?
这是我用于创建UUID的代码
public static String uuid()
{
UUID uuid = UUID.randomUUID();
long hi = uuid.getMostSignificantBits();
long lo = uuid.getLeastSignificantBits();
byte[] bytes = ByteBuffer.allocate(16).putLong(hi).putLong(lo).array();
BigInteger big = new BigInteger(bytes);
String numericUuid = big.toString().replace('-','1'); // just in case
//System.out.println(numericUuid);
return(numericUuid);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试学习一些套接字编程,我对 c 也很陌生,并且在创建服务器时遇到了一些问题。
我在指针方面遇到问题,当我尝试运行代码时出现的错误是
警告:将“int *”传递给“socklen_t *”类型的参数(又名“unsigned int *”)会在指针之间转换为具有不同符号的整数类型[-Wpointer-sign]`
我的服务器代码如下,任何人都可以帮助解决我收到的错误吗?也欢迎任何其他提示或评论
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
int main( int argc, char *argv[] )
{
int sockfd, newsockfd, portno, clilen;
char buffer[256];
struct sockaddr_in serv_addr, cli_addr;
int n;
/* First call to socket() function */
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
{
perror("ERROR opening socket");
exit(1);
}
/* Initialize socket structure */
bzero((char *) &serv_addr, sizeof(serv_addr)); …Run Code Online (Sandbox Code Playgroud)