小编Sha*_*nas的帖子

如何让android-studio中的文本动画?

例如,如果我在TextView中显示文本"上传",我现在希望它将文本显示为"正在上传...",并且要删除的3个点再次显示,就像处理某事而不仅仅是静态文本一样.

我在MainActivity onTouch事件中有这个:

@Override
        public boolean onTouchEvent(MotionEvent event)
        {
            float eventX = event.getX();
            float eventY = event.getY();

            float lastdownx = 0;
            float lastdowny = 0;

            switch (event.getAction())
            {
                case MotionEvent.ACTION_DOWN:
                    lastdownx = eventX;
                    lastdowny = eventY;

                    Thread t = new Thread(new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            byte[] response = null;
                            if (connectedtoipsuccess == true)
                            {

                                if (is_start == true)
                                {
                                    uploadTimerBool = true;
                                    timers.StartTimer(timerValueRecord, "Recording Time: ");
                                    response = Get(iptouse + "start");
                                    is_start = false;
                                } else
                                { …
Run Code Online (Sandbox Code Playgroud)

java android-studio

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

如何将变量传递给Runnable?

MainActivity我有一个Runnable,我想传递变量.我尝试添加TextView timerValueRunnable()我的第二个例子,但是这是不正确的做法.

private Runnable updateTimerThread = new Runnable() {

    public void run() {

        timeInMilliseconds = SystemClock.uptimeMillis() - startTime;

        updatedTime = timeSwapBuff + timeInMilliseconds;

        int secs = (int) (timeInMilliseconds / 1000);
        int mins = secs / 60;
        secs = secs % 60;
        int hours = mins / 60;
        mins = mins % 60;
        recordtimer = "Recording Time: " + String.format("%02d", hours) + ":" + String.format("%02d", mins) + ":" + String.format("%02d", secs);
        timerValueRecord.post(new Runnable()
        {
            public …
Run Code Online (Sandbox Code Playgroud)

java

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

如何读取文本文件键值并将值分配给字符串变量?

我使用StreamWriter和在新类中创建了一个文本文件WriteLine.我构建的每一行都是这样的:

w.WriteLine("key2" + "=" + value2);
w.WriteLine("key1" + "=" + value1);
Run Code Online (Sandbox Code Playgroud)

然后在form1 Load事件中:

string[] lines = File.ReadAllLines(FileName);
Run Code Online (Sandbox Code Playgroud)

现在我在索引0"key2 = value2"和索引1中的行"key1 = value1"现在我想将每个值分配给另一个字符串,例如:

string1赋值key1的key1和string2赋值key2的key2

有时可以更改行的顺序,文本文件中的第一行可以是value2和key2或value1和key1,但在所有情况下,我希望为字符串value1分配key1的value1,将字符串value2赋值为value2 key2

这次我手动构建了文本文件,没有keyvaluepair或类似的东西但是当读回来时我想读取左边​​的含义作为键,并且在=作为值之后.

但如果我在做:

string[] lines = File.ReadAllLines(Authentication.AuthenticationFileName);
for (int i = 0; i < lines.Length; i++)
{

}
Run Code Online (Sandbox Code Playgroud)

我怎么知道总是按照我想要的顺序分配字符串无论文本文件中的行是否写入顺序?

我想知道如果我构建像键和值的文本文件它是如何工作的: key = value

.net c# winforms

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

如何在目录中的所有文件中搜索字符串?我出现了内存异常

我在form1构造函数中调用了两个方法:

DirSearch(@"D:\C-Sharp");
SearchInFiles();
Run Code Online (Sandbox Code Playgroud)

DirSearch方法:

public static void DirSearch(string sDir)
        {
            try
            {
                foreach (string d in Directory.GetDirectories(sDir))
                {
                    foreach (string f in Directory.GetFiles(d))
                    {
                        files.Add(f);
                    }
                    DirSearch(d);
                }
            }
            catch (System.Exception excpt)
            {
                Console.WriteLine(excpt.Message);
            }
        }
Run Code Online (Sandbox Code Playgroud)

而SearchInfiles方法:

private void SearchInFiles()
        {
            for (int i = 0; i < files.Count; i++)
            {
                string[] lines = File.ReadAllLines(files[i]);
                for (int x = 0; x < lines.Length; x++)
                {
                    if (lines[x].Contains("setting"))
                    {
                        filesContent.Add(lines[x]);
                    }
                }
            }
        }
Run Code Online (Sandbox Code Playgroud)

我在线路上的内存异常:

string[] lines = File.ReadAllLines(files[i]);
Run Code Online (Sandbox Code Playgroud)

如果可能的话,如何更快地进行搜索?如何避免此异常?

也许我需要以某种方式使它不会在dll文件和其他文件中搜索不可编辑的文件,例如*.cs和*.txt这样的文件我怎么能这样做?

.net c# winforms

-1
推荐指数
1
解决办法
107
查看次数

标签 统计

.net ×2

c# ×2

java ×2

winforms ×2

android-studio ×1