我有一个php脚本,我希望使用bash脚本运行,所以我可以使用Cron每分钟运行一次php脚本.
据我所知,我需要创建bash脚本来处理php脚本,然后允许我使用Cron工具/计时器.
到目前为止我被告知我需要放:
#!/pathtoscript/testphp.php
Run Code Online (Sandbox Code Playgroud)
在我的PHP脚本的开头.我不知道该怎么办......
有什么建议?谢谢.
我在向XML创建的布局中添加按钮时遇到了问题.这就是我想要实现的目标:
//some class
else {
startActivity(new Intent(StatisticsScreen.this, ScreenTemperature.class));
}
////
//ScreenTemperatureClass
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//this is where I call another class that
//displays a nice graph
setContentView(new GraphTemperature(getApplicationContext()));
}
Run Code Online (Sandbox Code Playgroud)
我想在Button这个新屏幕上添加一个,以便它显示在图表下方.我已经尝试创建一个LinearLayout视图,然后创建一个Button并将其添加到此视图但我只是得到了NullPointerException...
任何帮助,将不胜感激.谢谢
编辑#1
这是我尝试使用的创建了一个NullPointerException'强制关闭':
Button buybutton;
LinearLayout layout;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new GraphTemperature(getApplicationContext()));
layout = (LinearLayout) findViewById(R.id.statsviewlayout);
Button buyButton = new Button(this);
buyButton.setText(R.string.button_back);
buyButton.setLayoutParams(new LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
layout.addView(buyButton);
}
Run Code Online (Sandbox Code Playgroud)
这是logcat错误:
ERROR/AndroidRuntime(293): java.lang.RuntimeException: Unable …Run Code Online (Sandbox Code Playgroud) 我希望下面的类显示一些textview/buttons/spinners,以及包含已解析数据的ListView.但是listview/adapter/addview会造成一些麻烦.这是我得到的错误:
java.lang.UnsupportedOperationException:AdapterView不支持addView(View,LayoutParams)
我感觉它与我的xml文件有关,但我不太确定.这是我的代码:
public class StatisticsScreen extends ListActivity{
private List<Message> messages;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.statisticsscreen);
loadFeed();
//other textviews and listeners added
}
private void loadFeed() {
try{
BaseFeedParser parser = new BaseFeedParser();
messages = parser.parse();
List<String> titles = new ArrayList<String>(messages.size());
for (Message msg : messages){
titles.add(msg.getTitle());
}
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this, R.layout.xmldatarow,titles);
this.setListAdapter(adapter);
} catch (Throwable t){
Log.e("AndroidNews",t.getMessage(),t);
}
}
Run Code Online (Sandbox Code Playgroud)
我的statisticsscreen xml:
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:id="@+id/statsviewlayout"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/black">
//other layouts/textviews/buttons added …Run Code Online (Sandbox Code Playgroud) 我想在固定点周围连续旋转360度图像.我已经看过几个例子,例如:
RotateAnimation anim = new RotateAnimation(0, 360,150,150);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(2000);
[imageview].startAnimation(anim);
Run Code Online (Sandbox Code Playgroud)
这会旋转图像,但它会在弧/圆形路径上旋转.IE浏览器.图像以圆周运动方式移动/旋转,但不会固定在它的起始位置.
我基本上想要的是模仿WindMill手臂的旋转.
有什么想法吗?
我需要计算直到特定日期/时间的剩余时间(天/小时).
但是,我没有使用静态日期.
想象一下,我每个星期天的 17:00都有一个活动.我需要显示直到下一个事件的剩余时间,即即将到来的星期日17:00.
我在这个答案中找到了以下代码.它适用于静态日期/时间,但显然不是我正在寻找的.
$now = new DateTime();
$future_date = new DateTime('2011-05-11 12:00:00');
$interval = $future_date->diff($now);
echo $interval->format("%d days, %h hours, %i minutes, %s seconds");
Run Code Online (Sandbox Code Playgroud)
谢谢你的时间.
我目前正在使用故事板功能来定位视图.由于这些视图的性质,它们需要精确定位.
我想在放大/缩放级别大于100%的情况下查看故事板场景/视图,但似乎无法使用标准放大/缩小功能.
是否有可能做到这一点?
注意 - 我了解如何使用'尺寸检查器'.
我使用下面的代码在短暂的持续时间后更改UIImageView的图像.正如您所见,正在使用的图像存储在一个数组中.
问题是,无论我设置的"持续时间"或"延迟",图像视图几乎立即变为阵列中的最后一个图像.
我应该使用主线程在每次图像转换之间添加延迟吗?
////////////////////////////////////////////////////////////////
animationCount = 0;
imageArray =[NSMutableArray new];
[imageArray addObject:[UIImage imageNamed:@"gauge1final.png"]];
[imageArray addObject:[UIImage imageNamed:@"gauge2final.png"]];
[imageArray addObject:[UIImage imageNamed:@"gauge3final.png"]];
[imageArray addObject:[UIImage imageNamed:@"gauge4final.png"]];
[imageArray addObject:[UIImage imageNamed:@"gauge5final.png"]];
[self multiStageAnimate];
////////////////////////////////////////////////////////////////
-(void) multiStageAnimate{
[UIView animateWithDuration:5.0
delay:5.0
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^
{
self.gauge.image = [imageArray objectAtIndex:animationCount];
}
completion:^(BOOL finished){
animationCount ++;
if(animationCount < imageArray.count){
[self multiStageAnimate];
}
else
{
animationCount = 0;
}
}];
}
Run Code Online (Sandbox Code Playgroud)