小编Ant*_*met的帖子

获取C中的当前时间

我想得到我系统的当前时间.为此,我在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)

问题是这段代码给出了一些随机时间.此外,随机时间每次都不同.我想要我系统的当前时间.

c time time-t localtime

89
推荐指数
6
解决办法
42万
查看次数

如何使用Java运行时使用"cd"命令?

我创建了一个独立的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)

谁能告诉我如何实施它?

java terminal cd runtime runtime.exec

49
推荐指数
4
解决办法
8万
查看次数

AutoCompleteTextview默认情况下颜色设置为白色

我在我的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 colors autocompletetextview

23
推荐指数
3
解决办法
2万
查看次数

如何获取环境变量的值?

可能重复:
访问shell环境变量Java

我在linux中创建了一个独立的java应用程序.

如何获取环境变量的值(例如,在.bashrc文件中分配).

java linux environment-variables

13
推荐指数
2
解决办法
3万
查看次数

在android中自动启动新活动

我正在创建一个Android应用程序.我有一个logo screen(Activity)然后是我的home screen(another activity).我希望当我启动我的应用程序时,我的徽标屏幕应该会在2秒后自动显示我的主屏幕.任何人都可以向我建议我应该做什么?

android android-activity

5
推荐指数
1
解决办法
5623
查看次数

如何知道jtextarea是否有任何变化?

我创建了一个jtextarea,用户可以在其中修改其内容.我想知道,如果有任何办法,用户是否在关闭应用程序之前修改了其内容.请帮忙.
-提前致谢

java swing jtextarea

4
推荐指数
1
解决办法
7281
查看次数

如何在Android中旋转画布上绘制的矩形?

我正在使用下面的代码在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画布中绘制的矩形?

android rotation rect draw android-canvas

4
推荐指数
1
解决办法
1万
查看次数