这是我的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
.
我想这样做:
$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.
我计划编写一个应用程序,它将在后台每隔5分钟执行一次任务.如果手机进入睡眠状态会怎样?
我听说在深度睡眠时,cpu关闭,所以应用程序停止执行,有人还说cpu没有关闭,但运行频率低于100mhz?哪一个是真的?
另外,如果应用程序没有深度睡眠,我们如何实时接听电话和短信?
我是Android新手,刚刚安装了sdk.
我有这样的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?
我正在使用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
在列表项上做些什么.回到true
上longClickListener
工作正常(消耗click事件).但我也需要得到项目的ID,组和儿童的位置,这是通过提供ContextMenuInfo
的contextmenu
唯一听众.
我设法获得了屏幕截图,但结果是这样的:
原来的:
这是我从几个来源获取的代码:
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) 我试图在同一个活动中制作一个标签界面.这是我的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)