我很困惑如何在活动发生变化时触发事件.我知道的一件事是使用onWindowFocusChanged()方法,但我不知道如何使用它.请帮助一个例子,即当活动改变时,它应该显示一个吐司说"活动改变".
我有/home/backup/存储年度备份的目录.在备份文件夹中,我们有以下目录:
/home/backup/2012
/home/backup/2013
/home/backup/2014
/home/backup/2015
/home/backup/2016
/home/backup/2017
Run Code Online (Sandbox Code Playgroud)
每年我都要清理数据,只保留最后三年的备份.
在上面的例子中,我必须删除:
/home/backup/2012
/home/backup/2013
/home/backup/2014
Run Code Online (Sandbox Code Playgroud)
找到要删除的目录的最佳方法是什么?我有这个,但它不起作用:
find /home/ecentrix/recording/ -maxdepth 1 -mindepth 1 -type d -ctime +1095 -exec rm -rf {} \;
Run Code Online (Sandbox Code Playgroud)
你们有另一个想法吗?
我正在做一个Android项目.为什么ImageView id iv1和iv2不是全屏?我把我的XML放在这里:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout1"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="10px"
android:paddingLeft="10px"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/iv1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="invisible"
/>
<ImageView
android:id="@+id/iv2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="invisible"
/>
<ImageButton
android:id="@+id/menu_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/BunyiIng"
android:src="@drawable/menu_btn"
android:background="@null"
/>
<ImageView
android:id="@+id/image_logo"
android:src="@drawable/logo_vehicle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="5px"
/>
</RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
如果我将ImageViews放在LinearLayout中,它会阻止RelativeLayout.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout1"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="10px"
android:paddingLeft="10px"
>
<ImageView
android:id="@+id/iv1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="invisible"
/>
<ImageView
android:id="@+id/iv2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="invisible"
/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
> …Run Code Online (Sandbox Code Playgroud) 我正在为我的任务开发一个android项目.我正在尝试制作一个临时图像应用程序,你知道它就像我们划伤屏幕去除阻挡层来显示图像.但问题是我不知道从哪里开始.
我在stackoverflow中搜索与此相关的问题,但这没有帮助.从我在那里搜索,我发现这个项目正在使用的线索Bitmap.getPixel(int x, int y).
所以,在我的想法中,我必须从位图获取像素并将其绘制到画布上.但我不知道如何实施它?或者有人有更好的方法吗?
有人可以帮帮我吗?有关此类事物或相关主题的任何教程吗?
提前致谢!
这是我的示例代码:
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
tw = w;
th = h;
eraseableBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
mCanvas = new Canvas(eraseableBitmap);
Bitmap muteableBitmap = Bitmap.createBitmap(eraseableBitmap.getWidth(), eraseableBitmap.getHeight(), Bitmap.Config.ARGB_8888);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
static_x = event.getX();
static_y = event.getY();
if (event.getAction() == MotionEvent.ACTION_DOWN) {
touch_start(static_x, static_y);
} if (event.getAction() == MotionEvent.ACTION_MOVE) {
touch_move(static_x, static_y);
} if (event.getAction() == …Run Code Online (Sandbox Code Playgroud) 我的项目需要一些帮助.我在GridView中有一个ImageView.单击图像时我无法更改图像.提前致谢.