我想得到我系统的当前时间.为此,我在C中使用以下代码:
time_t now;
struct tm *mytime = localtime(&now);
if ( strftime(buffer, sizeof buffer, "%X", mytime) )
{
printf("time1 = \"%s\"\n", buffer);
}
Run Code Online (Sandbox Code Playgroud)
问题是这段代码给出了一些随机时间.此外,随机时间每次都不同.我想要我系统的当前时间.
我创建了一个独立的java应用程序,我正在尝试使用Ubuntu 10.04终端中的"cd"命令更改目录.我使用了以下代码.
String[] command = new String[]{"cd",path};
Process child = Runtime.getRuntime().exec(command, null);
Run Code Online (Sandbox Code Playgroud)
但上面的代码给出了以下错误
Exception in thread "main" java.io.IOException: Cannot run program "cd": java.io.IOException: error=2, No such file or directory
Run Code Online (Sandbox Code Playgroud)
谁能告诉我如何实施它?
我在我的Android应用程序中使用了AutoCompleteTextView,它运行正常.我面临的唯一问题是默认情况下建议的颜色是白色的,我无法看到任何建议.因此,当我开始输入内容时,列表会扩展为带有白色条目(不可见),但是当我点击任何项目时,我发现它正在按原样运行.只有颜色似乎是问题.我使用以下代码.
<AutoCompleteTextView android:id="@+id/location" android:textColor="#000000"
android:layout_width="fill_parent" android:layout_height="wrap_content"></AutoCompleteTextView>
Run Code Online (Sandbox Code Playgroud)
和
ArrayAdapter<String> autoadapter=new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line,cities);
city = (AutoCompleteTextView) findViewById(R.id.location);
city.setAdapter(autoadapter);
city.setThreshold(1);
city.setTextColor(Color.BLACK);
Run Code Online (Sandbox Code Playgroud)
谁能告诉我这是什么问题?
-提前致谢
我正在创建一个Android应用程序.我有一个logo screen(Activity)然后是我的home screen(another activity).我希望当我启动我的应用程序时,我的徽标屏幕应该会在2秒后自动显示我的主屏幕.任何人都可以向我建议我应该做什么?
我创建了一个jtextarea,用户可以在其中修改其内容.我想知道,如果有任何办法,用户是否在关闭应用程序之前修改了其内容.请帮忙.
-提前致谢
我正在使用下面的代码在android画布上绘制文本
Rect rect = new Rect();
paint.getTextBounds(text, 0, text.length(), rect);
canvas.translate(xPosition + position.getX(), yPosition + position.getY());
paint.setColor(Color.BLUE);
paint.setStyle(Style.STROKE);
canvas.drawRect(rect, paint);
paint.setStyle(Style.FILL);
paint.setColor(text_color);
canvas.translate(-(xPosition + position.getX()), -(yPosition + position.getY()));
canvas.rotate(getDegreesFromRadians(angle), xPosition + position.getX() + rect.exactCenterX(), yPosition + position.getY() + rect.exactCenterY());
canvas.drawText(text, xPosition + position.getX(), yPosition + position.getY(), paint);
Run Code Online (Sandbox Code Playgroud)
此代码负责文本的旋转,并且工作正常.我正在使用上面的代码在文本周围绘制一个蓝色矩形.现在我的问题是矩形不随文本一起旋转.它仍然保持不变.有没有办法旋转Android画布中绘制的矩形?