小编Sun*_*nny的帖子

Java:从特定字符后面的字符串中获取子字符串

我有一个字符串:

/abc/def/ghfj.doc
Run Code Online (Sandbox Code Playgroud)

我想从中提取ghfj.doc,即最后一个后的子串/,或者/右起第一个.

有人可以提供一些帮助吗?

java string substring

181
推荐指数
7
解决办法
36万
查看次数

C编程:如何将整个文件内容读入缓冲区

我想将文件的全部内容写入缓冲区.该文件实际上只包含一个我需要与字符串进行比较的字符串.

什么是最有效的选项,即使在Linux上也可以移植.

ENV:Windows

c file-io

75
推荐指数
2
解决办法
17万
查看次数

如何在Python中列出n个数字并随机选择任意数字?

我已经计算了一些东西,它出现在N.

现在我想有一个列表,其中包含0到N个数字.

例:

N = 5

然后, count_list = [1, 2, 3, 4, 5]

我怎么能这样做?

此外,一旦我创建了列表,我想从该列表中随机选择一个数字并使用该数字.

之后,我想从列表的剩余数字(N-1)中选择另一个数字,然后再使用它.

这样就可以了,列表是空的.

我怎样才能做到这一点?

python random list

25
推荐指数
2
解决办法
10万
查看次数

无法通过xcodebuild从命令行执行测试

我正在尝试使用iOS测试用例的命令行来构建和运行测试用例.我给出了以下命令:

xcodebuild -target AppEngineTests -configuration Debug -sdk iphonesimulator TEST_AFTER_BUILD=YES clean build
Run Code Online (Sandbox Code Playgroud)

它构建应用程序,但不运行测试用例.

有人可以帮忙吗?谢谢

xcodebuild ios xctest

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

在HashMap中返回put()的值:Java

我无法理解HashMap中put()的返回值的解释

  private Map<Bookmark, Integer> mDevice = new HashMap<String, Integer>();

    String abc = "two"
    Integer ret = mDevice.put(abc, ONLINE);
Run Code Online (Sandbox Code Playgroud)

我说的如下:

  1. 如果abc键已经存在且值为"OFFLINE",则ret等于OFFLINE
  2. 如果abc键已经存在且值为"ONLINE",则ret等于ONLINE
  3. 如果abc key不存在,则ret等于null.

谢谢.

java syntax dictionary

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

在同步块内执行新线程

如果我在同步块中创建一个新线程,该块是否会保持锁定状态,直到线程执行完成?如果没有,那么它什么时候会被锁定?

String sLine;
onClick(String line){
    synchronized (lock) {
        sLine = line;
        new Thread(new Runnable() {
            @Override
            public void run() {
                 doProcessing(Sline);    
        }).start(); 
    }
}
Run Code Online (Sandbox Code Playgroud)

java synchronized

12
推荐指数
1
解决办法
2697
查看次数

C:字段类型不完整

如果以前曾经问过,我道歉.

通过make编译时出现以下错误:

.../inc/intModIp.h:418: error: field 'cnc_id' has incomplete type
../inc/intModIp.h:419: error: field 'cnc_key' has incomplete type
../inc/intModIp.h:421: error: field 'fin_id' has incomplete type
../inc/intModIp.h:422: error: field 'fin_key' has incomplete type
../inc/intModIp.h:424: error: field 'remote_id' has incomplete type
../inc/intModIp.h:426: error: field 'cnc_ipsec_peer' has incomplete type
../inc/intModIp.h:427: error: field 'fin_ipsec_peer' has incomplete type
../inc/intModIp.h:428: error: field 'remote_ipsec_peer' has incomplete type
../inc/intModIp.h:430: error: field 'cnc_link' has incomplete type
../inc/intModIp.h:431: error: field 'cnc_esp' has incomplete type
../inc/intModIp.h:433: error: field 'fin_link' has incomplete type
../inc/intModIp.h:434: …
Run Code Online (Sandbox Code Playgroud)

c makefile

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

如何为使用canvas绘制的东西设置ontouch侦听器:Android

我有一个自定义视图,我在这个大圆的边缘画一个大圆圈和一个小圆圈.

我想移动小圆圈,所以我想只为小圆圈设一个ontouch听众.

有些人可以告诉我如何只为小圆圈设置ontouch监听器.

public class ThermoView extends View{

    private ImageView mThermostatBgrd;
    private ImageView mCurTempArrow;
    private ImageView mSetPointIndicator;
    public static final int THEMROSTAT_BACKGROUND = 0;
    public static final int THEMROSTAT_CURR_TEMP = 1;
    public static final int THEMROSTAT_SET_POINT = 2;

    private float mViewCentreX;
    private float mViewCentreY;
    private float mThermostatRadius;

    private Canvas mCanvas;
    private Paint mPaint;
    private Paint mPaintCurTemp;
    private Paint mPaintSetTemp;
    private Paint mPaintOverrideTemp;
    private Paint mPaintCurTempIndicator;

    private Boolean mManualOverride = false;
    private double mManualOverrideAngle;

    private int mMaxTemp = 420;
    private int …
Run Code Online (Sandbox Code Playgroud)

android ontouchlistener android-canvas

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

如何在Android中更改Switch的高度和宽度

  1. 我想把开关放在120dp宽度和30dp高度上.
  2. 另外我想在拇指上没有文字,但是想要将拇指盖在总宽度的一半,所以我希望它是60dp.
  3. 此外,我希望拇指的高度可以从三个侧面看到背景开关的高度.

我不知道如何做#3和#1和#2,我尝试了下面的xml,但它不起作用:

 <Switch
         android:id="@+id/plug_switch"
         android:layout_width="120dip"
         android:layout_height="10dp"
         android:maxHeight="10dp"
         android:layout_below="@id/plug_graph_layout"
         android:layout_centerHorizontal="true"
         android:minWidth="100dp"
         android:thumb="@drawable/plugs_button"
         android:track="@drawable/btntoggle_selector"
         android:textOn=""
        android:textOff=""
         android:width="120dip" />
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我#1,#2和#3.

谢谢

android switch-statement

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

ConstraintLayout:无法缩放图像以适合RecyclerView中的比例

  • 我有一个带有StaggeredGridLayoutManager的回收站视图.
  • 我在里面有自定义项目/视图.
  • 每个项目都被定义为ConstraintLayout,其中有一个图像应该具有恒定的宽高比.
  • 但是图像仍然能够缩放以适应每个跨度的宽度.
  • 然后根据比例调整高度.

但不知何故,图像并没有保持纵横比.

以下是用于创建回收站视图的xml文件和代码:

item.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:padding="10dp">


    <ImageView
        android:id="@+id/image"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintDimensionRatio="16:9"
        tools:src="@drawable/ic_logo" />


    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="@+id/image"
        android:textColor="@color/white"
        tools:text="SAMPLE"
        android:paddingBottom="10dp"
        android:layout_margin="5dp"/>

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_marginTop="5dp"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentStart="true" />

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

用于生成整个视图的代码:

adapter = new SampleAdapter(list);
        StaggeredGridLayoutManager manager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
        sampleRecyclerView.setLayoutManager(manager);
        sampleRecyclerView.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)

每个项目的宽度设置得很好,适合每个列跨度的宽度.但是高度没有保持,而且很少.

有人可以帮忙吗?

谢谢

android aspect-ratio android-recyclerview android-constraintlayout

8
推荐指数
1
解决办法
7255
查看次数