小编arn*_*321的帖子

无法在Nougat中强制转换为AnimatedVectorDrawableCompat

这是我的build.gradle

    defaultConfig {
    ...
    minSdkVersion 21
    targetSdkVersion 26
    vectorDrawables.useSupportLibrary = true
}
Run Code Online (Sandbox Code Playgroud)

和布局的一部分

<ImageView
    android:id="@+id/recents"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="?attr/selectableItemBackground"
    android:clickable="true"
    android:scaleType="fitCenter"
    app:srcCompat="@drawable/anim_test"/>
Run Code Online (Sandbox Code Playgroud)

和类演员:

val np = convertView.findViewById<ImageView>(R.id.recents)
val anim = np.drawable as AnimatedVectorDrawableCompat
Run Code Online (Sandbox Code Playgroud)

这在Lolipop(sdk 21)上按预期工作,但在Nougat上失败说:

android.graphics.drawable.AnimatedVectorDrawable cannot be cast to android.support.graphics.drawable.AnimatedVectorDrawableCompat
Run Code Online (Sandbox Code Playgroud)

我没有得到的是,为什么当系统已经支持AnimatedVectorDrawable时,它在sdk级别21上返回AnimatedVectorDrawableCompat.为什么它会在Nougat中返回AnimatedVectorDrawable而不管指定vectorDrawables.useSupportLibrary = true.

android android-vectordrawable

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

php/iis:无法打开流:权限被拒绝

我想这样做:

$fh = fopen("req2" , 'w')
Run Code Online (Sandbox Code Playgroud)

我得到:

警告:fopen(D:\ inetpub\wwwroot\req2)[function.fopen]:无法打开流:第44行的D:\ inetpub\wwwroot\test.php中的权限被拒绝无法打开文件

我在wwwroot目录中为IIS提供了"完全控制"权限.我也尝试过绝对路径:$_SERVER['DOCUMENT_ROOT']."\\req2"

但我仍然得到同样的错误.我在Windows 7上运行IIS 7.

php windows iis fopen

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

在深度睡眠模式下运行应用程序/服务?

我计划编写一个应用程序,它将在后台每隔5分钟执行一次任务.如果手机进入睡眠状态会怎样?

我听说在深度睡眠时,cpu关闭,所以应用程序停止执行,有人还说cpu没有关闭,但运行频率低于100mhz?哪一个是真的?

另外,如果应用程序没有深度睡眠,我们如何实时接听电话和短信?

我是Android新手,刚刚安装了sdk.

android

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

按条件选择单元格组?

我有这样的excel表:

Category     Gender      Age    Max male age
A             M          49
              F          38
              F          47
              M          41
B             M          49
              F          38
              F          47
              M          41

我想显示最大值 每个类别的男性年龄.每个类别中的人数不固定.这可能是使用excel公式,还是我必须使用VBA?

excel excel-formula

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

即使长按也可以执行Onclick事件

我正在使用ExpandableListView lv.这就是我所拥有的.

ExpandableListView lv=(ExpandableListView )findViewById(....);
lv.setOnChildClickListener(new ExpandableListView.OnChildClickListener(){
@Override
    public boolean onChildClick(ExpandableListView parent, View v,int gp, int cp, long id) {

        Toast.makeText(MainActivity.this, "Clicked", Toast.LENGTH_SHORT).show();
        //perform action    
        return true;
    }
});

lv.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
    @Override
    public void onCreateContextMenu(ContextMenu contextMenu, View v,ContextMenuInfo menuInfo) {     
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        customMenu.show(v);
        //do other stuff
        contextMenu=null;
    }
});
Run Code Online (Sandbox Code Playgroud)

当我长时间点击一个子项时,customMenu.show(v)会调用它,当我抬起手指时,它会OnClickListener被调用.类似地,在长按并然后在组项目上释放手指时,将ContextmenuListener调用它,然后该组将展开以显示子项目.这是正常的行为吗?我该如何防止这种情况?

我其实想long Click在列表项上做些什么.回到truelongClickListener工作正常(消耗click事件).但我也需要得到项目的ID,组和儿童的位置,这是通过提供ContextMenuInfocontextmenu唯一听众.

android listview

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

MediaProjection 生成扭曲的屏幕截图

我设法获得了屏幕截图,但结果是这样的:

截图已制作

原来的:

原来的

这是我从几个来源获取的代码:

final ImageReader ir = ImageReader.newInstance(width, height, PixelFormat.RGBA_8888, 2);
  VirtualDisplay vd= mediaProjection.createVirtualDisplay("screen", width, height, dpi, 
  DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY | DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC, ir.getSurface(), null, null);

final String path=getActivity().getFilesDir().getAbsolutePath()+"/myscreen.jpg";
  ir.setOnImageAvailableListener(new OnImageAvailableListener() {

          //  @Override
            public void onImageAvailable(ImageReader reader) {
                Image image = null;
                FileOutputStream fos = null;
                Bitmap bitmap = null;

                try {
                    image = ir.acquireLatestImage();
                    fos = new FileOutputStream( path);
                    final Image.Plane[] planes = image.getPlanes();
                    final Buffer buffer = planes[0].getBuffer().rewind();
                    bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
                    bitmap.copyPixelsFromBuffer(buffer);
                    bitmap.compress(CompressFormat.JPEG, 85, fos);
                    image.close();

                } catch …
Run Code Online (Sandbox Code Playgroud)

android android-screen android-mediaprojection

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

在选项卡中显示任何内容时出现NullPointerException

我试图在同一个活动中制作一个标签界面.这是我的main.xml

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/tabhost"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabWidget android:id="@android:id/tabs"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
    />
    <FrameLayout android:id="@android:id/tabcontent"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
      <AnalogClock android:id="@+id/tab1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
      />
      <Button android:id="@+id/tab2"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="A semi-random button"
      />
    </FrameLayout>
  </LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)

dummy.xml:

<?xml version="1.0" encoding="utf-8"?>

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:orientation="vertical" >

      <RatingBar
          android:id="@+id/ratingBar1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" />

  </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

和我的活动:

public class LActivity extends Activity {


 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.main);


     TabHost tabs=(TabHost)findViewById(R.id.tabhost); …
Run Code Online (Sandbox Code Playgroud)

android android-tabs

0
推荐指数
1
解决办法
272
查看次数