例如,如果我在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
{
timers.StopTimer(timerValueRecord);
textforthespeacch = "Recording stopped and preparing the file to be shared on youtube";
MainActivity.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
status1.setText("Preparing the file");
}
});
MainActivity.this.initTTS();
response = Get(iptouse + "stop");
is_start = true;
startuploadstatusthread = true;
servercheckCounter = 0;
}
if (response != null)
{
try
{
a = new String(response,"UTF-8");
MainActivity.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
if (a.equals("Recording started"))
{
status1.setText("Recording");
}
if (a.equals("Recording stopped and preparing the file to be shared on youtube"))
{
status1.setText("Recording Stopped");
}
}
});
textforthespeacch = a;
MainActivity.this.initTTS();
} catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
Logger.getLogger("MainActivity(inside thread)").info(a);
}
}
}
});
t.start();
return true;
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_UP:
break;
default:
return false;
}
return true;
}
这一行:
status1.setText("Preparing the file");
相反只显示静态文本“准备文件”我想知道如何使它显示诸如“准备文件……”之类的移动点,然后“准备文件……”和“准备文件”.再次“准备文件……”然后“准备文件……”等等.
最佳答案
使用这个真棒库,正是您正在寻找的:
https://github.com/tajchert/WaitingDots
https://github.com/tajchert/WaitingDots
将其添加到依赖项
compile 'pl.tajchert:waitingdots:0.2.0'